{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "# 使用PyTorch实现Chatbot\n",
    "\n",
    "本教程的主要内容翻译自[PyTorch官方教程](https://pytorch.org/tutorials/beginner/chatbot_tutorial.html)。\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 简介\n",
    "本教程会介绍使用seq2seq模型实现一个chatbot，使用的训练数据来自[Cornell电影对话语料库](https://www.cs.cornell.edu/~cristian/Cornell_Movie-Dialogs_Corpus.html)。对话系统是目前的研究热点，它在客服、可穿戴设备和智能家居等场景有广泛应用。传统的对话系统要么基于检索的方法——提前准备一个问答库，根据用户的输入寻找类似的问题和答案。这更像一个问答系统，它很难进行多轮的交互，而且答案是固定不变的。要么基于预先设置的对话流程，这主要用于slot-filling(Task-Oriented)的任务，比如查询机票需要用户提供日期，达到城市等信息。这种方法的缺点是比较死板，如果用户的意图在设计的流程之外，那么就无法处理，而且对话的流程也一般比较固定，要支持用户随意的话题内跳转和话题间切换比较困难。因此目前学术界的研究热点是根据大量的对话数据，自动的End-to-End的使用Seq2Seq模型学习对话模型。它的好处是不需要人来设计这个对话流程，完全是数据驱动的方法。它的缺点是流程不受人(开发者)控制，在严肃的场景(比如客服)下使用会有比较大的风险，而且需要大量的对话数据，这在很多实际应用中是很难得到的。因此目前更多的是用于类似小冰的闲聊机器人上。本文使用的[Cornell电影对话语料库](https://www.cs.cornell.edu/~cristian/Cornell_Movie-Dialogs_Corpus.html)就是偏向于闲聊的语料库。当然最近也有不少论文研究把这种方法用于task-oriented的任务，但还不是太成熟，在业界还很少被使用。\n",
    "\n",
    "下面是这个教程实现的对话效果示例：\n",
    "```\n",
    "> hello?\n",
    "Bot: hello .\n",
    "> where am I?\n",
    "Bot: you re in a hospital .\n",
    "> who are you?\n",
    "Bot: i m a lawyer .\n",
    "> how are you doing?\n",
    "Bot: i m fine .\n",
    "> are you my friend?\n",
    "Bot: no .\n",
    "> you're under arrest\n",
    "Bot: i m trying to help you !\n",
    "> i'm just kidding\n",
    "Bot: i m sorry .\n",
    "> where are you from?\n",
    "Bot: san francisco .\n",
    "> it's time for me to leave\n",
    "Bot: i know .\n",
    "> goodbye\n",
    "Bot: goodbye .\n",
    "```\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 准备\n",
    "\n",
    "首先我们通过[下载链接](http://www.cs.cornell.edu/~cristian/data/cornell_movie_dialogs_corpus.zip)下载训练语料库，这是一个zip文件，把它下载后到项目目录的子目录data下。接下来我们导入需要用到的模块，这主要是PyTorch的模块：\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from __future__ import absolute_import\n",
    "from __future__ import division\n",
    "from __future__ import print_function\n",
    "from __future__ import unicode_literals\n",
    "\n",
    "import torch\n",
    "from torch.jit import script, trace\n",
    "import torch.nn as nn\n",
    "from torch import optim\n",
    "import torch.nn.functional as F\n",
    "import csv\n",
    "import random\n",
    "import re\n",
    "import os\n",
    "import unicodedata\n",
    "import codecs\n",
    "from io import open\n",
    "import itertools\n",
    "import math\n",
    "\n",
    "\n",
    "USE_CUDA = torch.cuda.is_available()\n",
    "device = torch.device(\"cuda\" if USE_CUDA else \"cpu\")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 加载和预处理数据\n",
    "\n",
    "接下来我们需要对原始数据进行变换然后用合适的数据结构加载到内存里。\n",
    "\n",
    "[Cornell电影对话语料库](https://www.cs.cornell.edu/~cristian/Cornell_Movie-Dialogs_Corpus.html)是电影人物的对话数据，它包括：\n",
    "\n",
    "-  10,292对电影人物(一部电影有多个人物，他们两两之间可能存在对话)的220,579个对话\n",
    "-  617部电影的9,035个人物\n",
    "-  总共304,713个utterance(utterance是对话中的语音片段，不一定是完整的句子)\n",
    "\n",
    "这个数据集是比较大并且多样的(diverse)，语言形式、时代和情感都有很多样。这样的数据可以使得我们的chatbot对于不同的输入更加鲁棒(robust)。\n",
    "\n",
    "首先我们来看一下原始数据长什么样："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "b'L1045 +++$+++ u0 +++$+++ m0 +++$+++ BIANCA +++$+++ They do not!\\n'\n",
      "b'L1044 +++$+++ u2 +++$+++ m0 +++$+++ CAMERON +++$+++ They do to!\\n'\n",
      "b'L985 +++$+++ u0 +++$+++ m0 +++$+++ BIANCA +++$+++ I hope so.\\n'\n",
      "b'L984 +++$+++ u2 +++$+++ m0 +++$+++ CAMERON +++$+++ She okay?\\n'\n",
      "b\"L925 +++$+++ u0 +++$+++ m0 +++$+++ BIANCA +++$+++ Let's go.\\n\"\n",
      "b'L924 +++$+++ u2 +++$+++ m0 +++$+++ CAMERON +++$+++ Wow\\n'\n",
      "b\"L872 +++$+++ u0 +++$+++ m0 +++$+++ BIANCA +++$+++ Okay -- you're gonna need to learn how to lie.\\n\"\n",
      "b'L871 +++$+++ u2 +++$+++ m0 +++$+++ CAMERON +++$+++ No\\n'\n",
      "b'L870 +++$+++ u0 +++$+++ m0 +++$+++ BIANCA +++$+++ I\\'m kidding.  You know how sometimes you just become this \"persona\"?  And you don\\'t know how to quit?\\n'\n",
      "b'L869 +++$+++ u0 +++$+++ m0 +++$+++ BIANCA +++$+++ Like my fear of wearing pastels?\\n'\n"
     ]
    }
   ],
   "source": [
    "corpus_name = \"cornell movie-dialogs corpus\"\n",
    "corpus = os.path.join(\"data\", corpus_name)\n",
    "\n",
    "def printLines(file, n=10):\n",
    "    with open(file, 'rb') as datafile:\n",
    "        lines = datafile.readlines()\n",
    "    for line in lines[:n]:\n",
    "        print(line)\n",
    "\n",
    "printLines(os.path.join(corpus, \"movie_lines.txt\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 数据处理\n",
    "\n",
    "为了使用方便，我们会把原始数据处理成一个新的文件，这个新文件的每一行都是用TAB分割问题(query)和答案(response)对。为了实现这个目的，我们首先定义一些用于parsing原始文件 *movie_lines.txt*  的辅助函数。\n",
    "\n",
    " \n",
    "-  ``loadLines`` 把*movie_lines.txt* 文件切分成 (lineID, characterID, movieID, character, text)\n",
    "-  ``loadConversations`` 把上面的行group成一个个多轮的对话\n",
    "-  ``extractSentencePairs`` 从上面的每个对话中抽取句对\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 把每一行都parse成一个dict，key是lineID、characterID、movieID、character和text\n",
    "# 分别代表这一行的ID、人物ID、电影ID，人物名称和文本。\n",
    "# 最终输出一个dict，key是lineID，value是一个dict。\n",
    "# value这个dict的key是lineID、characterID、movieID、character和text\n",
    "def loadLines(fileName, fields):\n",
    "    lines = {}\n",
    "    with open(fileName, 'r', encoding='iso-8859-1') as f:\n",
    "        for line in f:\n",
    "            values = line.split(\" +++$+++ \")\n",
    "            # 抽取fields\n",
    "            lineObj = {}\n",
    "            for i, field in enumerate(fields):\n",
    "                lineObj[field] = values[i]\n",
    "            lines[lineObj['lineID']] = lineObj\n",
    "    return lines\n",
    "\n",
    "\n",
    "# 根据movie_conversations.txt文件和上输出的lines，把utterance组成对话。\n",
    "# 最终输出一个list，这个list的每一个元素都是一个dict，key分别是character1ID、character2ID、movieID和utteranceIDs。\n",
    "# 分别表示这对话的第一个人物的ID，第二个的ID，电影的ID以及它包含的utteranceIDs\n",
    "# 最后根据lines，还给每一行的dict增加一个key为lines，其value是个list，包含所有utterance(上面得到的lines的value)\n",
    "def loadConversations(fileName, lines, fields):\n",
    "    conversations = []\n",
    "    with open(fileName, 'r', encoding='iso-8859-1') as f:\n",
    "        for line in f:\n",
    "            values = line.split(\" +++$+++ \")\n",
    "            # 抽取fields\n",
    "            convObj = {}\n",
    "            for i, field in enumerate(fields):\n",
    "                convObj[field] = values[i]\n",
    "            # convObj[\"utteranceIDs\"]是一个字符串，形如['L198', 'L199']\n",
    "            # 我们用eval把这个字符串变成一个字符串的list。\n",
    "            lineIds = eval(convObj[\"utteranceIDs\"])\n",
    "            # 根据lineIds构造一个数组，根据lineId去lines里检索出存储utterance对象。\n",
    "            convObj[\"lines\"] = []\n",
    "            for lineId in lineIds:\n",
    "                convObj[\"lines\"].append(lines[lineId])\n",
    "            conversations.append(convObj)\n",
    "    return conversations\n",
    "\n",
    "\n",
    "# 从对话中抽取句对 \n",
    "# 假设一段对话包含s1,s2,s3,s4这4个utterance\n",
    "# 那么会返回3个句对：s1-s2,s2-s3和s3-s4。\n",
    "def extractSentencePairs(conversations):\n",
    "    qa_pairs = []\n",
    "    for conversation in conversations:\n",
    "        # 遍历对话中的每一个句子，忽略最后一个句子，因为没有答案。\n",
    "        for i in range(len(conversation[\"lines\"]) - 1): \n",
    "            inputLine = conversation[\"lines\"][i][\"text\"].strip()\n",
    "            targetLine = conversation[\"lines\"][i+1][\"text\"].strip()\n",
    "            # 如果有空的句子就去掉 \n",
    "            if inputLine and targetLine:\n",
    "                qa_pairs.append([inputLine, targetLine])\n",
    "    return qa_pairs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "接下来我们利用上面的3个函数对原始数据进行处理，最终得到*formatted_movie_lines.txt*。\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Processing corpus...\n",
      "\n",
      "Loading conversations...\n",
      "\n",
      "Writing newly formatted file...\n",
      "\n",
      "Sample lines from file:\n",
      "b\"Can we make this quick?  Roxanne Korrine and Andrew Barrett are having an incredibly horrendous public break- up on the quad.  Again.\\tWell, I thought we'd start with pronunciation, if that's okay with you.\\n\"\n",
      "b\"Well, I thought we'd start with pronunciation, if that's okay with you.\\tNot the hacking and gagging and spitting part.  Please.\\n\"\n",
      "b\"Not the hacking and gagging and spitting part.  Please.\\tOkay... then how 'bout we try out some French cuisine.  Saturday?  Night?\\n\"\n",
      "b\"You're asking me out.  That's so cute. What's your name again?\\tForget it.\\n\"\n",
      "b\"No, no, it's my fault -- we didn't have a proper introduction ---\\tCameron.\\n\"\n",
      "b\"Cameron.\\tThe thing is, Cameron -- I'm at the mercy of a particularly hideous breed of loser.  My sister.  I can't date until she does.\\n\"\n",
      "b\"The thing is, Cameron -- I'm at the mercy of a particularly hideous breed of loser.  My sister.  I can't date until she does.\\tSeems like she could get a date easy enough...\\n\"\n",
      "b'Why?\\tUnsolved mystery.  She used to be really popular when she started high school, then it was just like she got sick of it or something.\\n'\n",
      "b\"Unsolved mystery.  She used to be really popular when she started high school, then it was just like she got sick of it or something.\\tThat's a shame.\\n\"\n",
      "b'Gosh, if only we could find Kat a boyfriend...\\tLet me see what I can do.\\n'\n"
     ]
    }
   ],
   "source": [
    "# 定义新的文件 \n",
    "datafile = os.path.join(corpus, \"formatted_movie_lines.txt\")\n",
    "\n",
    "delimiter = '\\t'\n",
    "# 对分隔符delimiter进行decode，这里对tab进行decode结果并没有变\n",
    "delimiter = str(codecs.decode(delimiter, \"unicode_escape\"))\n",
    "\n",
    "# 初始化dict lines，list conversations以及前面我们介绍过的field的id数组。\n",
    "lines = {}\n",
    "conversations = []\n",
    "MOVIE_LINES_FIELDS = [\"lineID\", \"characterID\", \"movieID\", \"character\", \"text\"]\n",
    "MOVIE_CONVERSATIONS_FIELDS = [\"character1ID\", \"character2ID\", \"movieID\", \"utteranceIDs\"]\n",
    "\n",
    "# 首先使用loadLines函数处理movie_lines.txt \n",
    "print(\"\\nProcessing corpus...\")\n",
    "lines = loadLines(os.path.join(corpus, \"movie_lines.txt\"), MOVIE_LINES_FIELDS)\n",
    "# 接着使用loadConversations处理上一步的结果，得到conversations\n",
    "print(\"\\nLoading conversations...\")\n",
    "conversations = loadConversations(os.path.join(corpus, \"movie_conversations.txt\"),\n",
    "                                  lines, MOVIE_CONVERSATIONS_FIELDS)\n",
    "\n",
    "# 输出到一个新的csv文件\n",
    "print(\"\\nWriting newly formatted file...\")\n",
    "with open(datafile, 'w', encoding='utf-8') as outputfile:\n",
    "    writer = csv.writer(outputfile, delimiter=delimiter, lineterminator='\\n')\n",
    "    # 使用extractSentencePairs从conversations里抽取句对。\n",
    "    for pair in extractSentencePairs(conversations):\n",
    "        writer.writerow(pair)\n",
    "\n",
    "# 输出一些行用于检查 \n",
    "print(\"\\nSample lines from file:\")\n",
    "printLines(datafile)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 创建词典\n",
    "\n",
    "\n",
    "接下来我们需要构建词典然后把问答句对加载到内存里。\n",
    "\n",
    "\n",
    "我们的输入是一个句对，每个句子都是词的序列，但是机器学习只能处理数值，因此我们需要建立词到数字ID的映射。\n",
    "\n",
    "为此，我们会定义一个``Voc``类，它会保存词到ID的映射，同时也保存反向的从ID到词的映射。除此之外，它还记录每个词出现的次数，以及总共出现的词的个数。这个类提供``addWord``方法来增加一个词， ``addSentence``方法来增加句子，也提供方法``trim``来去除低频的词。\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 预定义的token\n",
    "PAD_token = 0  # 表示padding \n",
    "SOS_token = 1  # 句子的开始 \n",
    "EOS_token = 2  # 句子的结束 \n",
    "\n",
    "class Voc:\n",
    "    def __init__(self, name):\n",
    "        self.name = name\n",
    "        self.trimmed = False\n",
    "        self.word2index = {}\n",
    "        self.word2count = {}\n",
    "        self.index2word = {PAD_token: \"PAD\", SOS_token: \"SOS\", EOS_token: \"EOS\"}\n",
    "        self.num_words = 3  # 目前有SOS, EOS, PAD这3个token。\n",
    "\n",
    "    def addSentence(self, sentence):\n",
    "        for word in sentence.split(' '):\n",
    "            self.addWord(word)\n",
    "\n",
    "    def addWord(self, word):\n",
    "        if word not in self.word2index:\n",
    "            self.word2index[word] = self.num_words\n",
    "            self.word2count[word] = 1\n",
    "            self.index2word[self.num_words] = word\n",
    "            self.num_words += 1\n",
    "        else:\n",
    "            self.word2count[word] += 1\n",
    "\n",
    "    # 删除频次小于min_count的token \n",
    "    def trim(self, min_count):\n",
    "        if self.trimmed:\n",
    "            return\n",
    "        self.trimmed = True\n",
    "\n",
    "        keep_words = []\n",
    "\n",
    "        for k, v in self.word2count.items():\n",
    "            if v >= min_count:\n",
    "                keep_words.append(k)\n",
    "\n",
    "        print('keep_words {} / {} = {:.4f}'.format(\n",
    "            len(keep_words), len(self.word2index), len(keep_words) / len(self.word2index)\n",
    "        ))\n",
    "\n",
    "        # 重新构造词典 \n",
    "        self.word2index = {}\n",
    "        self.word2count = {}\n",
    "        self.index2word = {PAD_token: \"PAD\", SOS_token: \"SOS\", EOS_token: \"EOS\"}\n",
    "        self.num_words = 3 # Count default tokens\n",
    "        \n",
    "        # 重新构造后词频就没有意义了(都是1)\n",
    "        for word in keep_words:\n",
    "            self.addWord(word)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "有了上面的Voc类我们就可以通过问答句对来构建词典了。但是在构建之前我们需要进行一些预处理。\n",
    "\n",
    "首先我们需要使用函数``unicodeToAscii``来把unicode字符变成ascii，比如把à变成a。注意，这里的代码只是用于处理西方文字，如果是中文，这个函数直接会丢弃掉。接下来把所有字母变成小写同时丢弃掉字母和常见标点(.!?)之外的所有字符。最后为了训练收敛，我们会用函数``filterPairs``去掉长度超过``MAX_LENGTH``的句子(句对)。\n",
    " \n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Start preparing training data ...\n",
      "Reading lines...\n",
      "Read 221282 sentence pairs\n",
      "Trimmed to 64271 sentence pairs\n",
      "Counting words...\n",
      "Counted words: 18008\n",
      "\n",
      "pairs:\n",
      "['there .', 'where ?']\n",
      "['you have my word . as a gentleman', 'you re sweet .']\n",
      "['hi .', 'looks like things worked out tonight huh ?']\n",
      "['you know chastity ?', 'i believe we share an art instructor']\n",
      "['have fun tonight ?', 'tons']\n",
      "['well no . . .', 'then that s all you had to say .']\n",
      "['then that s all you had to say .', 'but']\n",
      "['but', 'you always been this selfish ?']\n",
      "['do you listen to this crap ?', 'what crap ?']\n",
      "['what good stuff ?', 'the real you .']\n"
     ]
    }
   ],
   "source": [
    "MAX_LENGTH = 10  # 句子最大长度是10个词(包括EOS等特殊词)\n",
    "\n",
    "# 把Unicode字符串变成ASCII\n",
    "# 参考https://stackoverflow.com/a/518232/2809427\n",
    "def unicodeToAscii(s):\n",
    "    return ''.join(\n",
    "        c for c in unicodedata.normalize('NFD', s)\n",
    "        if unicodedata.category(c) != 'Mn'\n",
    "    )\n",
    " \n",
    "def normalizeString(s):\n",
    "    # 变成小写、去掉前后空格，然后unicode变成ascii\n",
    "    s = unicodeToAscii(s.lower().strip())\n",
    "    # 在标点前增加空格，这样把标点当成一个词\n",
    "    s = re.sub(r\"([.!?])\", r\" \\1\", s)\n",
    "    # 字母和标点之外的字符都变成空格\n",
    "    s = re.sub(r\"[^a-zA-Z.!?]+\", r\" \", s)\n",
    "    # 因为把不用的字符都变成空格，所以可能存在多个连续空格\n",
    "    # 下面的正则替换把多个空格变成一个空格，最后去掉前后空格\n",
    "    s = re.sub(r\"\\s+\", r\" \", s).strip()\n",
    "    return s\n",
    "\n",
    "# 读取问答句对并且返回Voc词典对象 \n",
    "def readVocs(datafile, corpus_name):\n",
    "    print(\"Reading lines...\")\n",
    "    # 文件每行读取到list lines中。 \n",
    "    lines = open(datafile, encoding='utf-8').\\\n",
    "        read().strip().split('\\n')\n",
    "    # 每行用tab切分成问答两个句子，然后调用normalizeString函数进行处理。\n",
    "    pairs = [[normalizeString(s) for s in l.split('\\t')] for l in lines]\n",
    "    voc = Voc(corpus_name)\n",
    "    return voc, pairs\n",
    "\n",
    "def filterPair(p): \n",
    "    return len(p[0].split(' ')) < MAX_LENGTH and len(p[1].split(' ')) < MAX_LENGTH\n",
    "\n",
    "# 过滤太长的句对 \n",
    "def filterPairs(pairs):\n",
    "    return [pair for pair in pairs if filterPair(pair)]\n",
    "\n",
    "# 使用上面的函数进行处理，返回Voc对象和句对的list \n",
    "def loadPrepareData(corpus, corpus_name, datafile):\n",
    "    print(\"Start preparing training data ...\")\n",
    "    voc, pairs = readVocs(datafile, corpus_name)\n",
    "    print(\"Read {!s} sentence pairs\".format(len(pairs)))\n",
    "    pairs = filterPairs(pairs)\n",
    "    print(\"Trimmed to {!s} sentence pairs\".format(len(pairs)))\n",
    "    print(\"Counting words...\")\n",
    "    for pair in pairs:\n",
    "        voc.addSentence(pair[0])\n",
    "        voc.addSentence(pair[1])\n",
    "    print(\"Counted words:\", voc.num_words)\n",
    "    return voc, pairs\n",
    "\n",
    "\n",
    "# Load/Assemble voc and pairs\n",
    "save_dir = os.path.join(\"data\", \"save\")\n",
    "voc, pairs = loadPrepareData(corpus, corpus_name, datafile)\n",
    "# 输出一些句对\n",
    "print(\"\\npairs:\")\n",
    "for pair in pairs[:10]:\n",
    "    print(pair)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "另外为了收敛更快，我们可以去除掉一些低频词。这可以分为两步：\n",
    "\n",
    "1) 使用``voc.trim``函数去掉频次低于``MIN_COUNT`` 的词。\n",
    "\n",
    "2) 去掉包含低频词的句子(只保留这样的句子——每一个词都是高频的，也就是在voc中出现的)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "keep_words 7823 / 18005 = 0.4345\n",
      "Trimmed from 64271 pairs to 53165, 0.8272 of total\n"
     ]
    }
   ],
   "source": [
    "MIN_COUNT = 3    # 阈值为3\n",
    "\n",
    "\n",
    "def trimRareWords(voc, pairs, MIN_COUNT):\n",
    "    # 去掉voc中频次小于3的词 \n",
    "    voc.trim(MIN_COUNT)\n",
    "    # 保留的句对 \n",
    "    keep_pairs = []\n",
    "    for pair in pairs:\n",
    "        input_sentence = pair[0]\n",
    "        output_sentence = pair[1]\n",
    "        keep_input = True\n",
    "        keep_output = True\n",
    "        # 检查问题\n",
    "        for word in input_sentence.split(' '):\n",
    "            if word not in voc.word2index:\n",
    "                keep_input = False\n",
    "                break\n",
    "        # 检查答案\n",
    "        for word in output_sentence.split(' '):\n",
    "            if word not in voc.word2index:\n",
    "                keep_output = False\n",
    "                break\n",
    "\n",
    "        # 如果问题和答案都只包含高频词，我们才保留这个句对\n",
    "        if keep_input and keep_output:\n",
    "            keep_pairs.append(pair)\n",
    "\n",
    "    print(\"Trimmed from {} pairs to {}, {:.4f} of total\".format(len(pairs), len(keep_pairs), len(keep_pairs) / len(pairs)))\n",
    "    return keep_pairs\n",
    "\n",
    "\n",
    "# 实际进行处理\n",
    "pairs = trimRareWords(voc, pairs, MIN_COUNT)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 为模型准备数据\n",
    "\n",
    "前面我们构建了词典，并且对训练数据进行预处理并且滤掉一些句对，但是模型最终用到的是Tensor。最简单的办法是一次处理一个句对，那么上面得到的句对直接就可以使用。但是为了加快训练速度，尤其是重复利用GPU的并行能力，我们需要一次处理一个batch的数据。\n",
    "\n",
    "对于某些问题，比如图像来说，输入可能是固定大小的(或者通过预处理缩放成固定大小），但是对于文本来说，我们很难把一个二十个词的句子\"缩放\"成十个词同时还保持语义不变。但是为了充分利用GPU等计算自由，我们又必须变成固定大小的Tensor，因此我们通常会使用Padding的技巧，把短的句子补充上零使得输入大小是(batch, max_length)，这样通过一次就能实现一个batch数据的forward或者backward计算。当然padding的部分的结果是没有意义的，比如某个句子实际长度是5，而max_length是10，那么最终forward的输出应该是第5个时刻的输出，后面5个时刻计算是无用功。方向计算梯度的时候也是类似的，我们需要从第5个时刻开始反向计算梯度。为了提高效率，通常把长度接近的训练数据放到一个batch里面，这样无用的计算是最少的。因此我们通常把全部训练数据根据长度划分成一些组，比如长度小于4的一组，长度4到8的一组，长度8到12的一组，...。然后每次随机的选择一个组，再随机的从一组里选择batch个数据。不过本教程并没有这么做，而是每次随机的从所有pair里随机选择batch个数据。\n",
    "\n",
    "原始的输入通常是batch个list，表示batch个句子，因此自然的表示方法为(batch, max_length)，这种表示方法第一维是batch，每移动一个下标得到的是一个样本的max_length个词(包括padding)。因为RNN的依赖关系，我们在计算t+1时刻必须知道t时刻的结果，因此我们无法用多个核同时计算一个样本的forward。但是不同样本之间是没有依赖关系的，因此我们可以在根据t时刻batch样本的当前状态计算batch个样本的输出和新状态，然后再计算t+2时刻，...。为了便于GPU一次取出t时刻的batch个数据，我们通常把输入从(batch, max_length)变成(max_length, batch)，这样使得t时刻的batch个数据在内存(显存)中是连续的，从而读取效率更高。这个过程如下图所示，原始输入的大小是(batch=6, max_length=4)，转置之后变成(4,6)。这样某个时刻的6个样本数据在内存中是连续的。\n",
    "\n",
    "![](seq2seq_batches.png)\n",
    "\n",
    " \n",
    "因此我们会用一些工具函数来实现上述处理。\n",
    "\n",
    "``inputVar``函数把batch个句子padding后变成一个LongTensor，大小是(max_length, batch)，同时会返回一个大小是batch的list lengths，说明每个句子的实际长度，这个参数后面会传给PyTorch，从而在forward和backward计算的时候使用实际的长度。\n",
    "\n",
    "``outputVar``函数和``inputVar``类似，但是它输出的第二个参数不是lengths，而是一个大小为(max_length, batch)的mask矩阵(tensor)，某位是0表示这个位置是padding，1表示不是padding，这样做的目的是后面计算方便。当然这两种表示是等价的，只不过lengths表示更加紧凑，但是计算起来不同方便，而mask矩阵和outputVar直接相乘就可以把padding的位置给mask(变成0)掉，这在计算loss时会非常方便。\n",
    "\n",
    "``batch2TrainData`` 则利用上面的两个函数把一个batch的句对处理成合适的输入和输出Tensor。\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "input_variable: tensor([[  682,   101,   318,    50,    62],\n",
      "        [    4,    37,     4,    37,     4],\n",
      "        [ 7665,  6099,    76,  4554,  2464],\n",
      "        [   37,   111,   334,     6,     4],\n",
      "        [  887,     4,     4,     2,     2],\n",
      "        [    4,     2,     2,     0,     0],\n",
      "        [    2,     0,     0,     0,     0]])\n",
      "lengths: tensor([ 7,  6,  6,  5,  5])\n",
      "target_variable: tensor([[  334,   101,   100,  2007,  2464],\n",
      "        [   76,   115,     6,    77,     4],\n",
      "        [  863,    67,     2,    12,     2],\n",
      "        [    6,  7638,     0,  2558,     0],\n",
      "        [    2,   111,     0,   115,     0],\n",
      "        [    0,     4,     0,     4,     0],\n",
      "        [    0,     2,     0,   276,     0],\n",
      "        [    0,     0,     0,  2613,     0],\n",
      "        [    0,     0,     0,     4,     0],\n",
      "        [    0,     0,     0,     2,     0]])\n",
      "mask: tensor([[ 1,  1,  1,  1,  1],\n",
      "        [ 1,  1,  1,  1,  1],\n",
      "        [ 1,  1,  1,  1,  1],\n",
      "        [ 1,  1,  0,  1,  0],\n",
      "        [ 1,  1,  0,  1,  0],\n",
      "        [ 0,  1,  0,  1,  0],\n",
      "        [ 0,  1,  0,  1,  0],\n",
      "        [ 0,  0,  0,  1,  0],\n",
      "        [ 0,  0,  0,  1,  0],\n",
      "        [ 0,  0,  0,  1,  0]], dtype=torch.uint8)\n",
      "max_target_len: 10\n"
     ]
    }
   ],
   "source": [
    "# 把句子的词变成ID\n",
    "def indexesFromSentence(voc, sentence):\n",
    "    return [voc.word2index[word] for word in sentence.split(' ')] + [EOS_token]\n",
    "\n",
    "# l是多个长度不同句子(list)，使用zip_longest padding成定长，长度为最长句子的长度。\n",
    "def zeroPadding(l, fillvalue=PAD_token):\n",
    "    return list(itertools.zip_longest(*l, fillvalue=fillvalue))\n",
    "\n",
    "# l是二维的padding后的list\n",
    "# 返回m和l的大小一样，如果某个位置是padding，那么值为0，否则为1\n",
    "def binaryMatrix(l, value=PAD_token):\n",
    "    m = []\n",
    "    for i, seq in enumerate(l):\n",
    "        m.append([])\n",
    "        for token in seq:\n",
    "            if token == PAD_token:\n",
    "                m[i].append(0)\n",
    "            else:\n",
    "                m[i].append(1)\n",
    "    return m\n",
    "\n",
    "# 把输入句子变成ID，然后再padding，同时返回lengths这个list，标识实际长度。\n",
    "# 返回的padVar是一个LongTensor，shape是(batch, max_length)，\n",
    "# lengths是一个list，长度为(batch,)，表示每个句子的实际长度。\n",
    "def inputVar(l, voc):\n",
    "    indexes_batch = [indexesFromSentence(voc, sentence) for sentence in l]\n",
    "    lengths = torch.tensor([len(indexes) for indexes in indexes_batch])\n",
    "    padList = zeroPadding(indexes_batch)\n",
    "    padVar = torch.LongTensor(padList)\n",
    "    return padVar, lengths\n",
    "\n",
    "# 对输出句子进行padding，然后用binaryMatrix得到每个位置是padding(0)还是非padding，\n",
    "# 同时返回最大最长句子的长度(也就是padding后的长度)\n",
    "# 返回值padVar是LongTensor，shape是(batch, max_target_length)\n",
    "# mask是ByteTensor，shape也是(batch, max_target_length)\n",
    "def outputVar(l, voc):\n",
    "    indexes_batch = [indexesFromSentence(voc, sentence) for sentence in l]\n",
    "    max_target_len = max([len(indexes) for indexes in indexes_batch])\n",
    "    padList = zeroPadding(indexes_batch)\n",
    "    mask = binaryMatrix(padList)\n",
    "    mask = torch.ByteTensor(mask)\n",
    "    padVar = torch.LongTensor(padList)\n",
    "    return padVar, mask, max_target_len\n",
    "\n",
    "# 处理一个batch的pair句对 \n",
    "def batch2TrainData(voc, pair_batch):\n",
    "    # 按照句子的长度(词数)排序\n",
    "    pair_batch.sort(key=lambda x: len(x[0].split(\" \")), reverse=True)\n",
    "    input_batch, output_batch = [], []\n",
    "    for pair in pair_batch:\n",
    "        input_batch.append(pair[0])\n",
    "        output_batch.append(pair[1])\n",
    "    inp, lengths = inputVar(input_batch, voc)\n",
    "    output, mask, max_target_len = outputVar(output_batch, voc)\n",
    "    return inp, lengths, output, mask, max_target_len\n",
    "\n",
    "\n",
    "# 示例\n",
    "small_batch_size = 5\n",
    "batches = batch2TrainData(voc, [random.choice(pairs) for _ in range(small_batch_size)])\n",
    "input_variable, lengths, target_variable, mask, max_target_len = batches\n",
    "\n",
    "print(\"input_variable:\", input_variable)\n",
    "print(\"lengths:\", lengths)\n",
    "print(\"target_variable:\", target_variable)\n",
    "print(\"mask:\", mask)\n",
    "print(\"max_target_len:\", max_target_len)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 定义模型\n",
    "\n",
    "\n",
    "### Seq2Seq 模型\n",
    "\n",
    "我们这个chatbot的核心是一个sequence-to-sequence(seq2seq)模型。 seq2seq模型的输入是一个变长的序列，而输出也是一个变长的序列。而且这两个序列的长度并不相同。一般我们使用RNN来处理变长的序列，Sutskever等人的[论文](https://arxiv.org/abs/1409.3215)发现通过使用两个RNN可以解决这类问题。这类问题的输入和输出都是变长的而且长度不一样，包括问答系统、机器翻译、自动摘要等等都可以使用seq2seq模型来解决。其中一个RNN叫做Encoder，它把变长的输入序列编码成一个固定长度的context向量，我们一般可以认为这个向量包含了输入句子的语义。而第二个RNN叫做Decoder，初始隐状态是Encoder的输出context向量，输入是<SOS>(表示句子开始的特殊Token)，然后用RNN计算第一个时刻的输出，接着用第一个时刻的输出和隐状态计算第二个时刻的输出和新的隐状态，...，直到某个时刻输出特殊的<EOS>(表示句子结束的特殊Token)或者长度超过一个阈值。\n",
    "\n",
    "Seq2Seq模型如下图所示。\n",
    "\n",
    "![Seq2Seq模型](seq2seq_ts.png)\n",
    " \n",
    "\n",
    "图像来源: https://jeddy92.github.io/JEddy92.github.io/ts_seq2seq_intro/\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Encoder\n",
    "\n",
    "Encoder是个RNN，它会遍历输入的每一个Token(词)，每个时刻的输入是上一个时刻的隐状态和输入，然后会有一个输出和新的隐状态。这个新的隐状态会作为下一个时刻的输入隐状态。每个时刻都有一个输出，对于seq2seq模型来说，我们通常只保留最后一个时刻的隐状态，认为它编码了整个句子的语义，但是后面我们会用到Attention机制，它还会用到Encoder每个时刻的输出。Encoder处理结束后会把最后一个时刻的隐状态作为Decoder的初始隐状态。\n",
    "\n",
    "实际我们通常使用多层的Gated Recurrent Unit(GRU)或者LSTM来作为Encoder，这里使用GRU，读者可以参考Cho等人2014年的[论文]。\n",
    "\n",
    "此外我们会使用双向的RNN，如下图所示。\n",
    "\n",
    "![](RNN-bidirectional.png)\n",
    "\n",
    "图片来源: https://colah.github.io/posts/2015-09-NN-Types-FP/\n",
    "\n",
    "注意在接入RNN之前会有一个``embedding``层，用来把每一个词(ID或者one-hot向量)映射成一个连续的稠密的向量，我们可以认为这个向量编码了一个词的语义。在我们的模型里，我们把它的大小定义成和RNN的隐状态大小一样(但是并不是一定要一样)。有了Embedding之后，模型会把相似的词编码成相似的向量(距离比较近)。\n",
    "\n",
    "最后，为了把padding的batch数据传给RNN，我们需要使用下面的两个函数来进行pack和unpack。这两个函数是：\n",
    "- ``torch.nn.utils.rnn.pack_padded_sequence`` \n",
    "- ``torch.nn.utils.rnn.pad_packed_sequence`` \n",
    "\n",
    "**计算图:**\n",
    "\n",
    "   1) 把词的ID通过Embedding层变成向量。\n",
    "   2) 把padding后的数据进行pack。 \n",
    "   3) 传入GRU进行Forward计算。 \n",
    "   4) Unpack计算结果\n",
    "   5) 把双向GRU的结果向量加起来。\n",
    "   6) 返回(所有时刻的)输出和最后时刻的隐状态。\n",
    "   \n",
    "**输入:**\n",
    "\n",
    "-  ``input_seq``: 一个batch的输入句子，shape是(max_length, batch_size)\n",
    "-  ``input_lengths``: 一个长度为batch的list，表示句子的实际长度。\n",
    "-  ``hidden``: 初始化隐状态(通常是零)，shape是(n_layers x num_directions, batch_size, hidden_size)\n",
    "\n",
    "**输出:**\n",
    "\n",
    "-  ``outputs``: 最后一层GRU的输出向量(双向的向量加在了一起)，shape(max_length, batch_size, hidden_size)\n",
    "-  ``hidden``: 最后一个时刻的隐状态，shape是(n_layers x num_directions, batch_size, hidden_size)\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "class EncoderRNN(nn.Module):\n",
    "    def __init__(self, hidden_size, embedding, n_layers=1, dropout=0):\n",
    "        super(EncoderRNN, self).__init__()\n",
    "        self.n_layers = n_layers\n",
    "        self.hidden_size = hidden_size\n",
    "        self.embedding = embedding\n",
    "\n",
    "        # 初始化GRU，这里输入和hidden大小都是hidden_size，因为我们这里假设embedding层的输出大小是hidden_size\n",
    "        # 如果只有一层，那么不进行Dropout，否则使用传入的参数dropout进行GRU的Dropout。\n",
    "        self.gru = nn.GRU(hidden_size, hidden_size, n_layers,\n",
    "                          dropout=(0 if n_layers == 1 else dropout), bidirectional=True)\n",
    "\n",
    "    def forward(self, input_seq, input_lengths, hidden=None):\n",
    "        # 输入是(max_length, batch)，Embedding之后变成(max_length, batch, hidden_size)\n",
    "        embedded = self.embedding(input_seq)\n",
    "        # Pack padded batch of sequences for RNN module\n",
    "        # 因为RNN(GRU)需要知道实际的长度，所以PyTorch提供了一个函数pack_padded_sequence把输入向量和长度pack\n",
    "        # 到一个对象PackedSequence里，这样便于使用。\n",
    "        packed = torch.nn.utils.rnn.pack_padded_sequence(embedded, input_lengths)\n",
    "        # 通过GRU进行forward计算，需要传入输入和隐变量\n",
    "        # 如果传入的输入是一个Tensor (max_length, batch, hidden_size)\n",
    "        # 那么输出outputs是(max_length, batch, hidden_size*num_directions)。\n",
    "        # 第三维是hidden_size和num_directions的混合，它们实际排列顺序是num_directions在前面，因此我们可以\n",
    "        # 使用outputs.view(seq_len, batch, num_directions, hidden_size)得到4维的向量。\n",
    "        # 其中第三维是方向，第四位是隐状态。\n",
    "        \n",
    "        # 而如果输入是PackedSequence对象，那么输出outputs也是一个PackedSequence对象，我们需要用\n",
    "        # 函数pad_packed_sequence把它变成一个shape为(max_length, batch, hidden*num_directions)的向量以及\n",
    "        # 一个list，表示输出的长度，当然这个list和输入的input_lengths完全一样，因此通常我们不需要它。\n",
    "        outputs, hidden = self.gru(packed, hidden)\n",
    "        # 参考前面的注释，我们得到outputs为(max_length, batch, hidden*num_directions)\n",
    "        outputs, _ = torch.nn.utils.rnn.pad_packed_sequence(outputs)\n",
    "        # 我们需要把输出的num_directions双向的向量加起来\n",
    "        # 因为outputs的第三维是先放前向的hidden_size个结果，然后再放后向的hidden_size个结果\n",
    "        # 所以outputs[:, :, :self.hidden_size]得到前向的结果\n",
    "        # outputs[:, :, self.hidden_size:]是后向的结果\n",
    "        # 注意，如果bidirectional是False，则outputs第三维的大小就是hidden_size，\n",
    "        # 这时outputs[:, : ,self.hidden_size:]是不存在的，因此也不会加上去。\n",
    "        # 对Python slicing不熟的读者可以看看下面的例子：\n",
    "        \n",
    "        # >>> a=[1,2,3]\n",
    "        # >>> a[:3]\n",
    "        # [1, 2, 3]\n",
    "        # >>> a[3:]\n",
    "        # []\n",
    "        # >>> a[:3]+a[3:]\n",
    "        # [1, 2, 3]\n",
    "        \n",
    "        # 这样就不用写下面的代码了：\n",
    "        # if bidirectional:\n",
    "        #     outputs = outputs[:, :, :self.hidden_size] + outputs[:, : ,self.hidden_size:]\n",
    "        outputs = outputs[:, :, :self.hidden_size] + outputs[:, : ,self.hidden_size:]\n",
    "        # 返回最终的输出和最后时刻的隐状态。 \n",
    "        return outputs, hidden"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Decoder\n",
    "\n",
    "Decoder也是一个RNN，它每个时刻输出一个词。每个时刻的输入是上一个时刻的隐状态和上一个时刻的输出。一开始的隐状态是Encoder最后时刻的隐状态，输入是特殊的<SOS>。然后使用RNN计算新的隐状态和输出第一个词，接着用新的隐状态和第一个词计算第二个词，...，直到遇到<EOS>，结束输出。普通的RNN Decoder的问题是它只依赖与Encoder最后一个时刻的隐状态，虽然理论上这个隐状态(context向量)可以编码输入句子的语义，但是实际会比较困难。因此当输入句子很长的时候，效果会很长。\n",
    "    \n",
    "为了解决这个问题，Bahdanau等人在[论文](https://arxiv.org/abs/1409.0473)里提出了注意力机制(attention mechanism)，在Decoder进行t时刻计算的时候，除了t-1时刻的隐状态，当前时刻的输入，注意力机制还可以参考Encoder所有时刻的输入。拿机器翻译来说，我们在翻译以句子的第t个词的时候会把注意力机制在某个词上。当然常见的注意力是一种soft的注意力，假设输入有5个词，注意力可能是一个概率，比如(0.6,0.1,0.1,0.1,0.1)，表示当前最关注的是输入的第一个词。同时我们之前也计算出每个时刻的输出向量，假设5个时刻分别是$y_1,...,y_5$，那么我们可以用attention概率加权得到当前时刻的context向量$0.6y_1+0.1y_2+...+0.1y_5$。\n",
    "\n",
    "\n",
    "注意力有很多方法计算，我们这里介绍Luong等人在[论文](https://arxiv.org/abs/1508.04025)提出的方法。它是用当前时刻的GRU计算出的新的隐状态来计算注意力得分，首先它用一个score函数计算这个隐状态和Encoder的输出的相似度得分，得分越大，说明越应该注意这个词。然后再用softmax函数把score变成概率。那机器翻译为例，在t时刻，$h_t$表示t时刻的GRU输出的新的隐状态，我们可以认为$h_t$表示当前需要翻译的语义。通过计算$h_t$与$y_1,...,y_n$的得分，如果$h_t$与$y_1$的得分很高，那么我们可以认为当前主要翻译词$x_1$的语义。有很多中score函数的计算方法，如下图所示：\n",
    "\n",
    "![](scores.png)\n",
    "\n",
    "上式中$h_t$表示t时刻的隐状态，比如第一种计算score的方法，直接计算$h_t$与$h_s$的内积，内积越大，说明这两个向量越相似，因此注意力也更多的放到这个词上。第二种方法也类似，只是引入了一个可以学习的矩阵，我们可以认为它先对$h_t$做一个线性变换，然后在与$h_s$计算内积。而第三种方法把它们拼接起来然后用一个全连接网络来计算score。\n",
    "\n",
    "注意，我们前面介绍的是分别计算$h_t$和$y_1$的内积、$h_t$和$y_2$的内积，...。但是为了效率，可以一次计算$h_t$与$h_s=[y_1,y_2,...,y_n]$的乘积。\n",
    "计算过程如下图所示。\n",
    "\n",
    "![](global_attn.png)\n",
    "\n",
    " \n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Luong 注意力layer\n",
    "class Attn(torch.nn.Module):\n",
    "    def __init__(self, method, hidden_size):\n",
    "        super(Attn, self).__init__()\n",
    "        self.method = method\n",
    "        if self.method not in ['dot', 'general', 'concat']:\n",
    "            raise ValueError(self.method, \"is not an appropriate attention method.\")\n",
    "        self.hidden_size = hidden_size\n",
    "        if self.method == 'general':\n",
    "            self.attn = torch.nn.Linear(self.hidden_size, hidden_size)\n",
    "        elif self.method == 'concat':\n",
    "            self.attn = torch.nn.Linear(self.hidden_size * 2, hidden_size)\n",
    "            self.v = torch.nn.Parameter(torch.FloatTensor(hidden_size))\n",
    "\n",
    "    def dot_score(self, hidden, encoder_output):\n",
    "        # 输入hidden的shape是(1, batch=64, hidden_size=500)\n",
    "        # encoder_outputs的shape是(input_lengths=10, batch=64, hidden_size=500)\n",
    "        # hidden * encoder_output得到的shape是(10, 64, 500)，然后对第3维求和就可以计算出score。\n",
    "        return torch.sum(hidden * encoder_output, dim=2)\n",
    "\n",
    "    def general_score(self, hidden, encoder_output):\n",
    "        energy = self.attn(encoder_output)\n",
    "        return torch.sum(hidden * energy, dim=2)\n",
    "\n",
    "    def concat_score(self, hidden, encoder_output):\n",
    "        energy = self.attn(torch.cat((hidden.expand(encoder_output.size(0), -1, -1), encoder_output), 2)).tanh()\n",
    "        return torch.sum(self.v * energy, dim=2)\n",
    "    \n",
    "    # 输入是上一个时刻的隐状态hidden和所有时刻的Encoder的输出encoder_outputs\n",
    "    # 输出是注意力的概率，也就是长度为input_lengths的向量，它的和加起来是1。\n",
    "    def forward(self, hidden, encoder_outputs):\n",
    "        # 计算注意力的score，输入hidden的shape是(1, batch=64, hidden_size=500),表示t时刻batch数据的隐状态\n",
    "        # encoder_outputs的shape是(input_lengths=10, batch=64, hidden_size=500) \n",
    "        if self.method == 'general':\n",
    "            attn_energies = self.general_score(hidden, encoder_outputs)\n",
    "        elif self.method == 'concat':\n",
    "            attn_energies = self.concat_score(hidden, encoder_outputs)\n",
    "        elif self.method == 'dot':\n",
    "            # 计算内积，参考dot_score函数\n",
    "            attn_energies = self.dot_score(hidden, encoder_outputs)\n",
    "\n",
    "        # Transpose max_length and batch_size dimensions\n",
    "        # 把attn_energies从(max_length=10, batch=64)转置成(64, 10)\n",
    "        attn_energies = attn_energies.t()\n",
    "\n",
    "        # 使用softmax函数把score变成概率，shape仍然是(64, 10)，然后用unsqueeze(1)变成\n",
    "        # (64, 1, 10) \n",
    "        return F.softmax(attn_energies, dim=1).unsqueeze(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "上面的代码实现了dot、general和concat三种score计算方法，分别和前面的三个公式对应，我们这里介绍最简单的dot方法。代码里也有一些注释，只有dot_score函数比较难以理解，我们来分析一下。首先这个函数的输入输入hidden的shape是(1, batch=64, hidden_size=500)，encoder_outputs的shape是(input_lengths=10, batch=64, hidden_size=500)。\n",
    "\n",
    "怎么计算hidden和10个encoder输出向量的内积呢？为了简便，我们先假设batch是1，这样可以把第二维(batch维)去掉，因此hidden是(1, 500)，而encoder_outputs是(10, 500)。内积的定义是两个向量对应位相乘然后相加，但是encoder_outputs是10个500维的向量。当然我们可以写一个for循环来计算，但是效率很低。这里用到一个小的技巧，利用broadcasting，hidden * encoder_outputs可以理解为把hidden从(1,500)复制成(10, 500)（当然实际实现并不会这么做），然后两个(10, 500)的矩阵进行乘法。注意，这里的乘法不是矩阵乘法，而是所谓的Hadamard乘法，其实就是把对应位置的乘起来，比如下面的例子：\n",
    "\n",
    "$$\n",
    "    \\begin{bmatrix}\n",
    "    1 & 2 & 3 \\\\\n",
    "    4 & 5 & 6\n",
    "    \\end{bmatrix} *\n",
    "    \\begin{bmatrix}\n",
    "    1 & 1 & 1 \\\\\n",
    "    2 & 2 & 2\n",
    "    \\end{bmatrix}=\n",
    "    \\begin{bmatrix}\n",
    "    1*1 & 2*1 & 3*1 \\\\\n",
    "    4*2 & 5*2 & 6*2\n",
    "    \\end{bmatrix}\n",
    "$$\n",
    "\n",
    "因此hidden * encoder_outputs就可以把hidden向量(500个数)与encoder_outputs的10个向量(500个数)对应的位置相乘。而内积还需要把这500个乘积加起来，因此后面使用torch.sum(hidden * encoder_output, dim=2)，把第2维500个乘积加起来，最终得到10个score值。当然我们实际还有一个batch维度，因此最终得到的attn_energies是(10, 64)。接着在forward函数里把attn_energies转置成(64, 10)，然后使用softmax函数把10个score变成概率，shape仍然是(64, 10)，为了后面使用方便，我们用unsqueeze(1)把它变成(64, 1, 10)。\n",
    "\n",
    "\n",
    "\n",
    "有了注意力的子模块之后，我们就可以实现Decoder了。Encoder可以一次把一个序列输入GRU，得到整个序列的输出。但是Decoder t时刻的输入是t-1时刻的输出，在t-1时刻计算完成之前是未知的，因此只能一次处理一个时刻的数据。因此Encoder的GRU的输入是(max_length, batch, hidden_size)，而Decoder的输入是(1, batch, hidden_size)。此外Decoder只能利用前面的信息，所以只能使用单向(而不是双向)的GRU，而Encoder的GRU是双向的，如果两种的hidden_size是一样的，则Decoder的隐单元个数少了一半，那怎么把Encoder的最后时刻的隐状态作为Decoder的初始隐状态呢？这里是把每个时刻双向结果加起来的，因此它们的大小就能匹配了（请读者参考前面Encoder双向相加的部分代码）。\n",
    "\n",
    "**计算图:**\n",
    "\n",
    "   1) 把词ID输入Embedding层 \n",
    "   2) 使用单向的GRU继续Forward进行一个时刻的计算。\n",
    "   3) 使用新的隐状态计算注意力权重 \n",
    "   4) 用注意力权重得到context向量 \n",
    "   5) context向量和GRU的输出拼接起来，然后再进过一个全连接网络，使得输出大小仍然是hidden_size\n",
    "   6) 使用一个投影矩阵把输出从hidden_size变成词典大小，然后用softmax变成概率\n",
    "   7) 返回输出和新的隐状态\n",
    "   \n",
    "**输入:**\n",
    "\n",
    "-  ``input_step``: shape是(1, batch_size) \n",
    "-  ``last_hidden``: 上一个时刻的隐状态， shape是(n_layers x num_directions, batch_size, hidden_size)\n",
    "-  ``encoder_outputs``: encoder的输出， shape是(max_length, batch_size, hidden_size)\n",
    "\n",
    "**输出:**\n",
    "\n",
    "-  ``output``: 当前时刻输出每个词的概率，shape是(batch_size, voc.num_words)\n",
    "-  ``hidden``: 新的隐状态，shape是(n_layers x num_directions, batch_size, hidden_size)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "class LuongAttnDecoderRNN(nn.Module):\n",
    "    def __init__(self, attn_model, embedding, hidden_size, output_size, n_layers=1, dropout=0.1):\n",
    "        super(LuongAttnDecoderRNN, self).__init__()\n",
    "\n",
    "        # 保存到self里，attn_model就是前面定义的Attn类的对象。\n",
    "        self.attn_model = attn_model\n",
    "        self.hidden_size = hidden_size\n",
    "        self.output_size = output_size\n",
    "        self.n_layers = n_layers\n",
    "        self.dropout = dropout\n",
    "\n",
    "        # 定义Decoder的layers\n",
    "        self.embedding = embedding\n",
    "        self.embedding_dropout = nn.Dropout(dropout)\n",
    "        self.gru = nn.GRU(hidden_size, hidden_size, n_layers, dropout=(0 if n_layers == 1 else dropout))\n",
    "        self.concat = nn.Linear(hidden_size * 2, hidden_size)\n",
    "        self.out = nn.Linear(hidden_size, output_size)\n",
    "\n",
    "        self.attn = Attn(attn_model, hidden_size)\n",
    "\n",
    "    def forward(self, input_step, last_hidden, encoder_outputs):\n",
    "        # 注意：decoder每一步只能处理一个时刻的数据，因为t时刻计算完了才能计算t+1时刻。\n",
    "        # input_step的shape是(1, 64)，64是batch，1是当前输入的词ID(来自上一个时刻的输出)\n",
    "        # 通过embedding层变成(1, 64, 500)，然后进行dropout，shape不变。\n",
    "        embedded = self.embedding(input_step)\n",
    "        embedded = self.embedding_dropout(embedded)\n",
    "        # 把embedded传入GRU进行forward计算\n",
    "        # 得到rnn_output的shape是(1, 64, 500)\n",
    "        # hidden是(2, 64, 500)，因为是双向的GRU，所以第一维是2。\n",
    "        rnn_output, hidden = self.gru(embedded, last_hidden)\n",
    "        # 计算注意力权重， 根据前面的分析，attn_weights的shape是(64, 1, 10)\n",
    "        attn_weights = self.attn(rnn_output, encoder_outputs)\n",
    "        \n",
    "        # encoder_outputs是(10, 64, 500) \n",
    "        # encoder_outputs.transpose(0, 1)后的shape是(64, 10, 500)\n",
    "        # attn_weights.bmm后是(64, 1, 500)\n",
    "        \n",
    "        # bmm是批量的矩阵乘法，第一维是batch，我们可以把attn_weights看成64个(1,10)的矩阵\n",
    "        # 把encoder_outputs.transpose(0, 1)看成64个(10, 500)的矩阵\n",
    "        # 那么bmm就是64个(1, 10)矩阵 x (10, 500)矩阵，最终得到(64, 1, 500)\n",
    "        context = attn_weights.bmm(encoder_outputs.transpose(0, 1))\n",
    "        # 把context向量和GRU的输出拼接起来\n",
    "        # rnn_output从(1, 64, 500)变成(64, 500)\n",
    "        rnn_output = rnn_output.squeeze(0)\n",
    "        # context从(64, 1, 500)变成(64, 500)\n",
    "        context = context.squeeze(1)\n",
    "        # 拼接得到(64, 1000)\n",
    "        concat_input = torch.cat((rnn_output, context), 1)\n",
    "        # self.concat是一个矩阵(1000, 500)，\n",
    "        # self.concat(concat_input)的输出是(64, 500)\n",
    "        # 然后用tanh把输出返回变成(-1,1)，concat_output的shape是(64, 500)\n",
    "        concat_output = torch.tanh(self.concat(concat_input))\n",
    "\n",
    "        # out是(500, 词典大小=7826)    \n",
    "        output = self.out(concat_output)\n",
    "        # 用softmax变成概率，表示当前时刻输出每个词的概率。\n",
    "        output = F.softmax(output, dim=1)\n",
    "        # 返回 output和新的隐状态 \n",
    "        return output, hidden"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 定义训练过程\n",
    "\n",
    "### Masked损失\n",
    "\n",
    "forward实现之后，我们就需要计算loss。seq2seq有两个RNN，Encoder RNN是没有直接定义损失函数的，它是通过影响Decoder从而影响最终的输出以及loss。Decoder输出一个序列，前面我们介绍的是Decoder在预测时的过程，它的长度是不固定的，只有遇到EOS才结束。给定一个问答句对，我们可以把问题输入Encoder，然后用Decoder得到一个输出序列，但是这个输出序列和\"真实\"的答案长度并不相同。\n",
    "\n",
    "而且即使长度相同并且语义相似，也很难直接知道预测的答案和真实的答案是否类似。那么我们怎么计算loss呢？比如输入是\"What is your name?\"，训练数据中的答案是\"I am LiLi\"。假设模型有两种预测：\"I am fine\"和\"My name is LiLi\"。从语义上显然第二种答案更好，但是如果字面上比较的话可能第一种更好。\n",
    "\n",
    "但是让机器知道\"I am LiLi\"和\"My name is LiLi\"的语义很接近这是非常困难的，所以实际上我们通常还是通过字面上里进行比较。我们会限制Decoder的输出，使得Decoder的输出长度和\"真实\"答案一样，然后逐个时刻比较。Decoder输出的是每个词的概率分布，因此可以使用交叉熵损失函数。但是这里还有一个问题，因为是一个batch的数据里有一些是padding的，因此这些位置的预测是没有必要计算loss的，因此我们需要使用前面的mask矩阵把对应位置的loss去掉，我们可以通过下面的函数来实现计算Masked的loss。\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "def maskNLLLoss(inp, target, mask):\n",
    "    # 计算实际的词的个数，因为padding是0，非padding是1，因此sum就可以得到词的个数\n",
    "    nTotal = mask.sum()\n",
    "    \n",
    "    crossEntropy = -torch.log(torch.gather(inp, 1, target.view(-1, 1)).squeeze(1))\n",
    "    loss = crossEntropy.masked_select(mask).mean()\n",
    "    loss = loss.to(device)\n",
    "    return loss, nTotal.item()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "上面的代码有几个需要注意的地方。首先是masked_select函数，我们来看一个例子：\n",
    "```\n",
    ">>> x = torch.randn(3, 4)\n",
    ">>> x\n",
    "tensor([[ 0.3552, -2.3825, -0.8297,  0.3477],\n",
    "        [-1.2035,  1.2252,  0.5002,  0.6248],\n",
    "        [ 0.1307, -2.0608,  0.1244,  2.0139]])\n",
    ">>> mask = x.ge(0.5)\n",
    ">>> mask\n",
    "tensor([[ 0,  0,  0,  0],\n",
    "        [ 0,  1,  1,  1],\n",
    "        [ 0,  0,  0,  1]], dtype=torch.uint8)\n",
    ">>> torch.masked_select(x, mask)\n",
    "tensor([ 1.2252,  0.5002,  0.6248,  2.0139])\n",
    "```\n",
    "它要求mask和被mask的tensor的shape是一样的，然后从crossEntropy选出mask值为1的那些值。输出的维度会减1。\n",
    "\n",
    "另外为了实现交叉熵这里使用了gather函数，这是一种比较底层的实现方法，更简便的方法应该使用CrossEntropyLoss或者NLLLoss，其中CrossEntropy等价与LogSoftmax+NLLLoss。\n",
    "\n",
    "交叉熵的定义为：$H(p,q)=-\\sum_xp(x)logq(x)$。其中p和q是两个随机变量的概率分布，这里是离散的随机变量，如果是连续的需要把求和变成积分。在我们这里p是真实的分布，也就是one-hot的，而q是模型预测的softmax的输出。因为p是one-hot的，所以只需要计算真实分类对应的那个值。\n",
    "\n",
    "比如假设一个5分类的问题，当前正确分类是2(下标从0-4)，而模型的预测是(0.1,0.1,0.4,0.2,0.2)，则H=-log(0.4)。用交叉熵作为分类的Loss是比较合理的，正确的分类是2，那么模型在下标为2的地方预测的概率$q_2$越大，则$-logq_2$越小，也就是loss越小。\n",
    "\n",
    "假设inp是：\n",
    "```\n",
    "0.3 0.2 0.4 0.1\n",
    "0.2 0.1 0.4 0.3\n",
    "```\n",
    "也就是batch=2，而分类数(词典大小)是4，inp是模型预测的分类概率。\n",
    "而target = [2,3] ，表示第一个样本的正确分类是第三个类别(概率是0.4），第二个样本的正确分类是第四个类别(概率是0.3)。因此我们需要计算的是 -log(0.4) - log(0.3)。怎么不用for循环求出来呢？我们可以使用torch.gather函数首先把0.4和0.3选出来：\n",
    "```\n",
    "inp = torch.tensor([[0.3, 0.2, 0.4, 0.1], [0.2, 0.1, 0.4, 0.3]])\n",
    "target = torch.tensor([2, 3])\n",
    "selected = torch.gather(inp, 1, target.view(-1, 1))\n",
    "print(selected)\n",
    "输出：\n",
    "tensor([[ 0.4000],\n",
    "        [ 0.3000]])\n",
    "```\n",
    "\n",
    "\n",
    "\n",
    "### 一次迭代的训练过程\n",
    "\n",
    "\n",
    "函数``train``实现一个batch数据的训练。前面我们提到过，在训练的时候我们会限制Decoder的输出，使得Decoder的输出长度和\"真实\"答案一样长。但是我们在训练的时候如果让Decoder自行输出，那么收敛可能会比较慢，因为Decoder在t时刻的输入来自t-1时刻的输出。如果前面预测错了，那么后面很可能都会错下去。另外一种方法叫做**teacher forcing**，它不管模型在t-1时刻做什么预测都把t-1时刻的正确答案作为t时刻的输入。但是如果只用teacher forcing也有问题，因为在真实的Decoder的是是没有老师来帮它纠正错误的。所以比较好的方法是更加一个teacher_forcing_ratio参数随机的来确定本次训练是否teacher forcing。\n",
    "\n",
    "另外使用到的一个技巧是**梯度裁剪(gradient clipping)** 。这个技巧通常是为了防止梯度爆炸(exploding gradient)，它把参数限制在一个范围之内，从而可以避免梯度的梯度过大或者出现NaN等问题。注意：虽然它的名字叫梯度裁剪，但实际它是对模型的参数进行裁剪，它把整个参数看成一个向量，如果这个向量的模大于max_norm，那么就把这个向量除以一个值使得模等于max_norm，因此也等价于把这个向量投影到半径为max_norm的球上。它的效果如下图所示。\n",
    "\n",
    "![](grad_clip.png)\n",
    " \n",
    "**操作步骤:**\n",
    "\n",
    "   1) 把整个batch的输入传入encoder \n",
    "   2) 把decoder的输入设置为特殊的<SOS>，初始隐状态设置为encoder最后时刻的隐状态\n",
    "   3) decoder每次处理一个时刻的forward计算 \n",
    "   4) 如果是teacher forcing，把上个时刻的\"正确的\"词作为当前输入，否则用上一个时刻的输出作为当前时刻的输入\n",
    "   5) 计算loss\n",
    "   6) 反向计算梯度 \n",
    "   7) 对梯度进行裁剪\n",
    "   8) 更新模型(包括encoder和decoder)参数 \n",
    "\n",
    "\n",
    "注意，PyTorch的RNN模块(``RNN``, ``LSTM``, ``GRU``)也可以当成普通的非循环的网络来使用。在Encoder部分，我们是直接把所有时刻的数据都传入RNN，让它一次计算出所有的结果，但是在Decoder的时候(非teacher forcing)后一个时刻的输入来自前一个时刻的输出，因此无法一次计算。\n",
    "  \n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "def train(input_variable, lengths, target_variable, mask, max_target_len, encoder, decoder, embedding,\n",
    "          encoder_optimizer, decoder_optimizer, batch_size, clip, max_length=MAX_LENGTH):\n",
    "\n",
    "    # 梯度清空\n",
    "    encoder_optimizer.zero_grad()\n",
    "    decoder_optimizer.zero_grad()\n",
    "\n",
    "    # 设置device，从而支持GPU，当然如果没有GPU也能工作。\n",
    "    input_variable = input_variable.to(device)\n",
    "    lengths = lengths.to(device)\n",
    "    target_variable = target_variable.to(device)\n",
    "    mask = mask.to(device)\n",
    "\n",
    "    # 初始化变量\n",
    "    loss = 0\n",
    "    print_losses = []\n",
    "    n_totals = 0\n",
    "\n",
    "    # encoder的Forward计算\n",
    "    encoder_outputs, encoder_hidden = encoder(input_variable, lengths)\n",
    "\n",
    "    # Decoder的初始输入是SOS，我们需要构造(1, batch)的输入，表示第一个时刻batch个输入。\n",
    "    decoder_input = torch.LongTensor([[SOS_token for _ in range(batch_size)]])\n",
    "    decoder_input = decoder_input.to(device)\n",
    "\n",
    "    # 注意：Encoder是双向的，而Decoder是单向的，因此从下往上取n_layers个\n",
    "    decoder_hidden = encoder_hidden[:decoder.n_layers]\n",
    "\n",
    "    # 确定是否teacher forcing\n",
    "    use_teacher_forcing = True if random.random() < teacher_forcing_ratio else False\n",
    "\n",
    "    # 一次处理一个时刻 \n",
    "    if use_teacher_forcing:\n",
    "        for t in range(max_target_len):\n",
    "            decoder_output, decoder_hidden = decoder(\n",
    "                decoder_input, decoder_hidden, encoder_outputs\n",
    "            )\n",
    "            # Teacher forcing: 下一个时刻的输入是当前正确答案\n",
    "            decoder_input = target_variable[t].view(1, -1)\n",
    "            # 计算累计的loss\n",
    "            mask_loss, nTotal = maskNLLLoss(decoder_output, target_variable[t], mask[t])\n",
    "            loss += mask_loss\n",
    "            print_losses.append(mask_loss.item() * nTotal)\n",
    "            n_totals += nTotal\n",
    "    else:\n",
    "        for t in range(max_target_len):\n",
    "            decoder_output, decoder_hidden = decoder(\n",
    "                decoder_input, decoder_hidden, encoder_outputs\n",
    "            )\n",
    "            # 不是teacher forcing: 下一个时刻的输入是当前模型预测概率最高的值\n",
    "            _, topi = decoder_output.topk(1)\n",
    "            decoder_input = torch.LongTensor([[topi[i][0] for i in range(batch_size)]])\n",
    "            decoder_input = decoder_input.to(device)\n",
    "            # 计算累计的loss\n",
    "            mask_loss, nTotal = maskNLLLoss(decoder_output, target_variable[t], mask[t])\n",
    "            loss += mask_loss\n",
    "            print_losses.append(mask_loss.item() * nTotal)\n",
    "            n_totals += nTotal\n",
    "\n",
    "    # 反向计算 \n",
    "    loss.backward()\n",
    "\n",
    "    # 对encoder和decoder进行梯度裁剪\n",
    "    _ = torch.nn.utils.clip_grad_norm_(encoder.parameters(), clip)\n",
    "    _ = torch.nn.utils.clip_grad_norm_(decoder.parameters(), clip)\n",
    "\n",
    "    # 更新参数\n",
    "    encoder_optimizer.step()\n",
    "    decoder_optimizer.step()\n",
    "\n",
    "    return sum(print_losses) / n_totals"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 训练迭代过程\n",
    "\n",
    "\n",
    "最后是把前面的代码组合起来进行训练。函数``trainIters``用于进行``n_iterations``次minibatch的训练。\n",
    "\n",
    "值得注意的是我们定期会保存模型，我们会保存一个tar包，包括encoder和decoder的state_dicts(参数),优化器(optimizers)的state_dicts, loss和迭代次数。这样保存模型的好处是从中恢复后我们既可以进行预测也可以进行训练(因为有优化器的参数和迭代的次数)。\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "def trainIters(model_name, voc, pairs, encoder, decoder, encoder_optimizer, decoder_optimizer, embedding, encoder_n_layers, decoder_n_layers, save_dir, n_iteration, batch_size, print_every, save_every, clip, corpus_name, loadFilename):\n",
    "\n",
    "    # 随机选择n_iteration个batch的数据(pair)\n",
    "    training_batches = [batch2TrainData(voc, [random.choice(pairs) for _ in range(batch_size)])\n",
    "                      for _ in range(n_iteration)]\n",
    "\n",
    "    # 初始化\n",
    "    print('Initializing ...')\n",
    "    start_iteration = 1\n",
    "    print_loss = 0\n",
    "    if loadFilename:\n",
    "        start_iteration = checkpoint['iteration'] + 1\n",
    "\n",
    "    # 训练\n",
    "    print(\"Training...\")\n",
    "    for iteration in range(start_iteration, n_iteration + 1):\n",
    "        training_batch = training_batches[iteration - 1]\n",
    "        \n",
    "        input_variable, lengths, target_variable, mask, max_target_len = training_batch\n",
    "\n",
    "        # 训练一个batch的数据\n",
    "        loss = train(input_variable, lengths, target_variable, mask, max_target_len, encoder,\n",
    "                     decoder, embedding, encoder_optimizer, decoder_optimizer, batch_size, clip)\n",
    "        print_loss += loss\n",
    "\n",
    "        # 进度\n",
    "        if iteration % print_every == 0:\n",
    "            print_loss_avg = print_loss / print_every\n",
    "            print(\"Iteration: {}; Percent complete: {:.1f}%; Average loss: {:.4f}\".format(iteration, iteration / n_iteration * 100, print_loss_avg))\n",
    "            print_loss = 0\n",
    "\n",
    "        # 保存checkpoint\n",
    "        if (iteration % save_every == 0):\n",
    "            directory = os.path.join(save_dir, model_name, corpus_name, '{}-{}_{}'.format(encoder_n_layers, decoder_n_layers, hidden_size))\n",
    "            if not os.path.exists(directory):\n",
    "                os.makedirs(directory)\n",
    "            torch.save({\n",
    "                'iteration': iteration,\n",
    "                'en': encoder.state_dict(),\n",
    "                'de': decoder.state_dict(),\n",
    "                'en_opt': encoder_optimizer.state_dict(),\n",
    "                'de_opt': decoder_optimizer.state_dict(),\n",
    "                'loss': loss,\n",
    "                'voc_dict': voc.__dict__,\n",
    "                'embedding': embedding.state_dict()\n",
    "            }, os.path.join(directory, '{}_{}.tar'.format(iteration, 'checkpoint')))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 效果测试\n",
    "\n",
    "模型训练完成之后，我们需要测试它的效果。最简单直接的方法就是和chatbot来聊天。因此我们需要用Decoder来生成一个响应。\n",
    "\n",
    "### 贪心解码(Greedy decoding)算法\n",
    "\n",
    "\n",
    "最简单的解码算法是贪心算法，也就是每次都选择概率最高的那个词，然后把这个词作为下一个时刻的输入，直到遇到EOS结束解码或者达到一个最大长度。但是贪心算法不一定能得到最优解，因为某个答案可能开始的几个词的概率并不太高，但是后来概率会很大。因此除了贪心算法，我们通常也可以使用Beam-Search算法，也就是每个时刻保留概率最高的Top K个结果，然后下一个时刻尝试把这K个结果输入(当然需要能恢复RNN的状态)，然后再从中选择概率最高的K个。\n",
    "\n",
    "为了实现贪心解码算法，我们定义一个``GreedySearchDecoder``类。这个类的forwar的方法需要传入一个输入序列(``input_seq``)，其shape是(input_seq length, 1)， 输入长度input_length和最大输出长度``max_length``。就是过程如下：\n",
    " \n",
    "\n",
    "   1) 把输入传给Encoder，得到所有时刻的输出和最后一个时刻的隐状态。 \n",
    "   2) 把Encoder最后时刻的隐状态作为Decoder的初始状态。\n",
    "   3) Decoder的第一输入初始化为SOS。\n",
    "   4) 定义保存解码结果的tensor \n",
    "   5) 循环直到最大解码长度 \n",
    "       a) 把当前输入传入Decoder\n",
    "       b) 得到概率最大的词以及概率\n",
    "       c) 把这个词和概率保存下来 \n",
    "       d) 把当前输出的词作为下一个时刻的输入 \n",
    "   6) 返回所有的词和概率\n",
    "   \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "class GreedySearchDecoder(nn.Module):\n",
    "    def __init__(self, encoder, decoder):\n",
    "        super(GreedySearchDecoder, self).__init__()\n",
    "        self.encoder = encoder\n",
    "        self.decoder = decoder\n",
    "\n",
    "    def forward(self, input_seq, input_length, max_length):\n",
    "        # Encoder的Forward计算 \n",
    "        encoder_outputs, encoder_hidden = self.encoder(input_seq, input_length)\n",
    "        # 把Encoder最后时刻的隐状态作为Decoder的初始值\n",
    "        decoder_hidden = encoder_hidden[:decoder.n_layers]\n",
    "        # 因为我们的函数都是要求(time,batch)，因此即使只有一个数据，也要做出二维的。\n",
    "        # Decoder的初始输入是SOS\n",
    "        decoder_input = torch.ones(1, 1, device=device, dtype=torch.long) * SOS_token\n",
    "        # 用于保存解码结果的tensor\n",
    "        all_tokens = torch.zeros([0], device=device, dtype=torch.long)\n",
    "        all_scores = torch.zeros([0], device=device)\n",
    "        # 循环，这里只使用长度限制，后面处理的时候把EOS去掉了。\n",
    "        for _ in range(max_length):\n",
    "            # Decoder forward一步\n",
    "            decoder_output, decoder_hidden = self.decoder(decoder_input, decoder_hidden, encoder_outputs)\n",
    "            # decoder_outputs是(batch=1, vob_size)\n",
    "            # 使用max返回概率最大的词和得分\n",
    "            decoder_scores, decoder_input = torch.max(decoder_output, dim=1)\n",
    "            # 把解码结果保存到all_tokens和all_scores里\n",
    "            all_tokens = torch.cat((all_tokens, decoder_input), dim=0)\n",
    "            all_scores = torch.cat((all_scores, decoder_scores), dim=0)\n",
    "            # decoder_input是当前时刻输出的词的ID，这是个一维的向量，因为max会减少一维。\n",
    "            # 但是decoder要求有一个batch维度，因此用unsqueeze增加batch维度。\n",
    "            decoder_input = torch.unsqueeze(decoder_input, 0)\n",
    "        # 返回所有的词和得分。\n",
    "        return all_tokens, all_scores"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 自己对话函数\n",
    "\n",
    "\n",
    "解码方法完成后，我们写一个函数来测试从终端输入一个句子然后来看看chatbot的回复。我们需要用前面的函数来把句子分词，然后变成ID传入解码器，得到输出的ID后再转换成文字。我们会实现一个``evaluate``函数，由它来完成这些工作。我们需要把一个句子变成输入需要的格式——shape为(batch, max_length)，即使只有一个输入也需要增加一个batch维度。我们首先把句子分词，然后变成ID的序列，然后转置成合适的格式。此外我们还需要创建一个名为``lengths``的tensor，虽然只有一个，来表示输入的实际长度。接着我们构造类``GreedySearchDecoder``的实例``searcher``，然后用searcher来进行解码得到输出的ID，最后我们把这些ID变成词并且去掉EOS之后的内容。\n",
    "\n",
    "\n",
    "另外一个``evaluateInput``函数作为chatbot的用户接口，当运行它的时候，它会首先提示用户输入一个句子，然后使用``evaluate``来生成回复。然后继续对话直到用户输入\"q\"或者\"quit\"。如果用户输入的词不在词典里，我们会输出错误信息(当然还有一种办法是忽略这些词)然后提示用户重新输入。\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "def evaluate(encoder, decoder, searcher, voc, sentence, max_length=MAX_LENGTH):\n",
    "    ### 把输入的一个batch句子变成id\n",
    "    indexes_batch = [indexesFromSentence(voc, sentence)]\n",
    "    # 创建lengths tensor\n",
    "    lengths = torch.tensor([len(indexes) for indexes in indexes_batch])\n",
    "    # 转置 \n",
    "    input_batch = torch.LongTensor(indexes_batch).transpose(0, 1)\n",
    "    # 放到合适的设备上(比如GPU)\n",
    "    input_batch = input_batch.to(device)\n",
    "    lengths = lengths.to(device)\n",
    "    # 用searcher解码\n",
    "    tokens, scores = searcher(input_batch, lengths, max_length)\n",
    "    # ID变成词。\n",
    "    decoded_words = [voc.index2word[token.item()] for token in tokens]\n",
    "    return decoded_words\n",
    "\n",
    "\n",
    "def evaluateInput(encoder, decoder, searcher, voc):\n",
    "    input_sentence = ''\n",
    "    while(1):\n",
    "        try:\n",
    "            # 得到用户终端的输入\n",
    "            input_sentence = input('> ')\n",
    "            # 是否退出\n",
    "            if input_sentence == 'q' or input_sentence == 'quit': break\n",
    "            # 句子归一化\n",
    "            input_sentence = normalizeString(input_sentence)\n",
    "            # 生成响应Evaluate sentence\n",
    "            output_words = evaluate(encoder, decoder, searcher, voc, input_sentence)\n",
    "            # 去掉EOS后面的内容\n",
    "            words = []\n",
    "            for word in output_words:\n",
    "                if word == 'EOS':\n",
    "                    break\n",
    "                elif word != 'PAD':\n",
    "                    words.append(word)\n",
    "            print('Bot:', ' '.join(words))\n",
    "\n",
    "        except KeyError:\n",
    "            print(\"Error: Encountered unknown word.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 训练和测试模型\n",
    "\n",
    "最后我们可以来训练模型和进行评测了。 \n",
    "\n",
    "不论是我们像训练模型还是测试对话，我们都需要初始化encoder和decoder模型参数。在下面的代码，我们从头开始训练模型或者从某个checkpoint加载模型。读者可以尝试不同的超参数配置来进行调优。\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Building encoder and decoder ...\n",
      "Models built and ready to go!\n"
     ]
    }
   ],
   "source": [
    "# 配置模型\n",
    "model_name = 'cb_model'\n",
    "attn_model = 'dot'\n",
    "#attn_model = 'general'\n",
    "#attn_model = 'concat'\n",
    "hidden_size = 500\n",
    "encoder_n_layers = 2\n",
    "decoder_n_layers = 2\n",
    "dropout = 0.1\n",
    "batch_size = 64\n",
    "\n",
    "# 从哪个checkpoint恢复，如果是None，那么从头开始训练。\n",
    "loadFilename = None\n",
    "checkpoint_iter = 4000\n",
    "  \n",
    "\n",
    "# 如果loadFilename不空，则从中加载模型 \n",
    "if loadFilename:\n",
    "    # 如果训练和加载是一条机器，那么直接加载 \n",
    "    checkpoint = torch.load(loadFilename)\n",
    "    # 否则比如checkpoint是在GPU上得到的，但是我们现在又用CPU来训练或者测试，那么注释掉下面的代码\n",
    "    #checkpoint = torch.load(loadFilename, map_location=torch.device('cpu'))\n",
    "    encoder_sd = checkpoint['en']\n",
    "    decoder_sd = checkpoint['de']\n",
    "    encoder_optimizer_sd = checkpoint['en_opt']\n",
    "    decoder_optimizer_sd = checkpoint['de_opt']\n",
    "    embedding_sd = checkpoint['embedding']\n",
    "    voc.__dict__ = checkpoint['voc_dict']\n",
    "\n",
    "\n",
    "print('Building encoder and decoder ...')\n",
    "# 初始化word embedding\n",
    "embedding = nn.Embedding(voc.num_words, hidden_size)\n",
    "if loadFilename:\n",
    "    embedding.load_state_dict(embedding_sd)\n",
    "# 初始化encoder和decoder模型\n",
    "encoder = EncoderRNN(hidden_size, embedding, encoder_n_layers, dropout)\n",
    "decoder = LuongAttnDecoderRNN(attn_model, embedding, hidden_size, voc.num_words, decoder_n_layers, dropout)\n",
    "if loadFilename:\n",
    "    encoder.load_state_dict(encoder_sd)\n",
    "    decoder.load_state_dict(decoder_sd)\n",
    "# 使用合适的设备\n",
    "encoder = encoder.to(device)\n",
    "decoder = decoder.to(device)\n",
    "print('Models built and ready to go!')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 训练\n",
    "\n",
    "下面的代码进行训练，我们需要设置一些训练的超参数。初始化优化器，最后调用函数``trainIters``进行训练。\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Building optimizers ...\n",
      "Starting Training!\n",
      "Initializing ...\n",
      "Training...\n",
      "Iteration: 1; Percent complete: 0.0%; Average loss: 8.9611\n",
      "Iteration: 2; Percent complete: 0.1%; Average loss: 8.8544\n",
      "Iteration: 3; Percent complete: 0.1%; Average loss: 8.6994\n",
      "Iteration: 4; Percent complete: 0.1%; Average loss: 8.4781\n",
      "Iteration: 5; Percent complete: 0.1%; Average loss: 8.0461\n",
      "Iteration: 6; Percent complete: 0.1%; Average loss: 7.5171\n",
      "Iteration: 7; Percent complete: 0.2%; Average loss: 6.9852\n",
      "Iteration: 8; Percent complete: 0.2%; Average loss: 6.8159\n",
      "Iteration: 9; Percent complete: 0.2%; Average loss: 6.8743\n",
      "Iteration: 10; Percent complete: 0.2%; Average loss: 6.5950\n",
      "Iteration: 11; Percent complete: 0.3%; Average loss: 6.2395\n",
      "Iteration: 12; Percent complete: 0.3%; Average loss: 5.8174\n",
      "Iteration: 13; Percent complete: 0.3%; Average loss: 5.5038\n",
      "Iteration: 14; Percent complete: 0.4%; Average loss: 5.4692\n",
      "Iteration: 15; Percent complete: 0.4%; Average loss: 5.3978\n",
      "Iteration: 16; Percent complete: 0.4%; Average loss: 5.1887\n",
      "Iteration: 17; Percent complete: 0.4%; Average loss: 5.3521\n",
      "Iteration: 18; Percent complete: 0.4%; Average loss: 5.1923\n",
      "Iteration: 19; Percent complete: 0.5%; Average loss: 4.8618\n",
      "Iteration: 20; Percent complete: 0.5%; Average loss: 4.8285\n",
      "Iteration: 21; Percent complete: 0.5%; Average loss: 5.0104\n",
      "Iteration: 22; Percent complete: 0.5%; Average loss: 4.9191\n",
      "Iteration: 23; Percent complete: 0.6%; Average loss: 4.9838\n",
      "Iteration: 24; Percent complete: 0.6%; Average loss: 4.8964\n",
      "Iteration: 25; Percent complete: 0.6%; Average loss: 4.9055\n",
      "Iteration: 26; Percent complete: 0.7%; Average loss: 4.8912\n",
      "Iteration: 27; Percent complete: 0.7%; Average loss: 4.8354\n",
      "Iteration: 28; Percent complete: 0.7%; Average loss: 4.8351\n",
      "Iteration: 29; Percent complete: 0.7%; Average loss: 4.8593\n",
      "Iteration: 30; Percent complete: 0.8%; Average loss: 4.5377\n",
      "Iteration: 31; Percent complete: 0.8%; Average loss: 4.5715\n",
      "Iteration: 32; Percent complete: 0.8%; Average loss: 4.4768\n",
      "Iteration: 33; Percent complete: 0.8%; Average loss: 4.7506\n",
      "Iteration: 34; Percent complete: 0.9%; Average loss: 4.8651\n",
      "Iteration: 35; Percent complete: 0.9%; Average loss: 4.6328\n",
      "Iteration: 36; Percent complete: 0.9%; Average loss: 4.6139\n",
      "Iteration: 37; Percent complete: 0.9%; Average loss: 4.5962\n",
      "Iteration: 38; Percent complete: 0.9%; Average loss: 4.7492\n",
      "Iteration: 39; Percent complete: 1.0%; Average loss: 4.4536\n",
      "Iteration: 40; Percent complete: 1.0%; Average loss: 4.6267\n",
      "Iteration: 41; Percent complete: 1.0%; Average loss: 4.7273\n",
      "Iteration: 42; Percent complete: 1.1%; Average loss: 4.8013\n",
      "Iteration: 43; Percent complete: 1.1%; Average loss: 4.5583\n",
      "Iteration: 44; Percent complete: 1.1%; Average loss: 4.7120\n",
      "Iteration: 45; Percent complete: 1.1%; Average loss: 4.7241\n",
      "Iteration: 46; Percent complete: 1.1%; Average loss: 4.6326\n",
      "Iteration: 47; Percent complete: 1.2%; Average loss: 4.6348\n",
      "Iteration: 48; Percent complete: 1.2%; Average loss: 4.7110\n",
      "Iteration: 49; Percent complete: 1.2%; Average loss: 4.7066\n",
      "Iteration: 50; Percent complete: 1.2%; Average loss: 4.5859\n",
      "Iteration: 51; Percent complete: 1.3%; Average loss: 4.5321\n",
      "Iteration: 52; Percent complete: 1.3%; Average loss: 4.6477\n",
      "Iteration: 53; Percent complete: 1.3%; Average loss: 4.7395\n",
      "Iteration: 54; Percent complete: 1.4%; Average loss: 4.7993\n",
      "Iteration: 55; Percent complete: 1.4%; Average loss: 4.6242\n",
      "Iteration: 56; Percent complete: 1.4%; Average loss: 4.5227\n",
      "Iteration: 57; Percent complete: 1.4%; Average loss: 4.5148\n",
      "Iteration: 58; Percent complete: 1.5%; Average loss: 4.4071\n",
      "Iteration: 59; Percent complete: 1.5%; Average loss: 4.6194\n",
      "Iteration: 60; Percent complete: 1.5%; Average loss: 4.5668\n",
      "Iteration: 61; Percent complete: 1.5%; Average loss: 4.5652\n",
      "Iteration: 62; Percent complete: 1.6%; Average loss: 4.7384\n",
      "Iteration: 63; Percent complete: 1.6%; Average loss: 4.5605\n",
      "Iteration: 64; Percent complete: 1.6%; Average loss: 4.5454\n",
      "Iteration: 65; Percent complete: 1.6%; Average loss: 4.5229\n",
      "Iteration: 66; Percent complete: 1.7%; Average loss: 4.7647\n",
      "Iteration: 67; Percent complete: 1.7%; Average loss: 4.5431\n",
      "Iteration: 68; Percent complete: 1.7%; Average loss: 4.4023\n",
      "Iteration: 69; Percent complete: 1.7%; Average loss: 4.8935\n",
      "Iteration: 70; Percent complete: 1.8%; Average loss: 4.2539\n",
      "Iteration: 71; Percent complete: 1.8%; Average loss: 4.3897\n",
      "Iteration: 72; Percent complete: 1.8%; Average loss: 4.6762\n",
      "Iteration: 73; Percent complete: 1.8%; Average loss: 4.5919\n",
      "Iteration: 74; Percent complete: 1.8%; Average loss: 4.2979\n",
      "Iteration: 75; Percent complete: 1.9%; Average loss: 4.4812\n",
      "Iteration: 76; Percent complete: 1.9%; Average loss: 4.6790\n",
      "Iteration: 77; Percent complete: 1.9%; Average loss: 4.3547\n",
      "Iteration: 78; Percent complete: 1.9%; Average loss: 4.1443\n",
      "Iteration: 79; Percent complete: 2.0%; Average loss: 4.4366\n",
      "Iteration: 80; Percent complete: 2.0%; Average loss: 4.5848\n",
      "Iteration: 81; Percent complete: 2.0%; Average loss: 4.4629\n",
      "Iteration: 82; Percent complete: 2.1%; Average loss: 4.3932\n",
      "Iteration: 83; Percent complete: 2.1%; Average loss: 4.5571\n",
      "Iteration: 84; Percent complete: 2.1%; Average loss: 4.5655\n",
      "Iteration: 85; Percent complete: 2.1%; Average loss: 4.5890\n",
      "Iteration: 86; Percent complete: 2.1%; Average loss: 4.5332\n",
      "Iteration: 87; Percent complete: 2.2%; Average loss: 4.4996\n",
      "Iteration: 88; Percent complete: 2.2%; Average loss: 4.2072\n",
      "Iteration: 89; Percent complete: 2.2%; Average loss: 4.2957\n",
      "Iteration: 90; Percent complete: 2.2%; Average loss: 4.5755\n",
      "Iteration: 91; Percent complete: 2.3%; Average loss: 4.3803\n",
      "Iteration: 92; Percent complete: 2.3%; Average loss: 4.6315\n",
      "Iteration: 93; Percent complete: 2.3%; Average loss: 4.5070\n",
      "Iteration: 94; Percent complete: 2.4%; Average loss: 4.7608\n",
      "Iteration: 95; Percent complete: 2.4%; Average loss: 4.3708\n",
      "Iteration: 96; Percent complete: 2.4%; Average loss: 4.2966\n",
      "Iteration: 97; Percent complete: 2.4%; Average loss: 4.6823\n",
      "Iteration: 98; Percent complete: 2.5%; Average loss: 4.5000\n",
      "Iteration: 99; Percent complete: 2.5%; Average loss: 4.2894\n",
      "Iteration: 100; Percent complete: 2.5%; Average loss: 4.3029\n",
      "Iteration: 101; Percent complete: 2.5%; Average loss: 4.5771\n",
      "Iteration: 102; Percent complete: 2.5%; Average loss: 4.4979\n",
      "Iteration: 103; Percent complete: 2.6%; Average loss: 4.4469\n",
      "Iteration: 104; Percent complete: 2.6%; Average loss: 4.5574\n",
      "Iteration: 105; Percent complete: 2.6%; Average loss: 4.3168\n",
      "Iteration: 106; Percent complete: 2.6%; Average loss: 4.2879\n",
      "Iteration: 107; Percent complete: 2.7%; Average loss: 4.3685\n",
      "Iteration: 108; Percent complete: 2.7%; Average loss: 4.2513\n",
      "Iteration: 109; Percent complete: 2.7%; Average loss: 4.6054\n",
      "Iteration: 110; Percent complete: 2.8%; Average loss: 4.1929\n",
      "Iteration: 111; Percent complete: 2.8%; Average loss: 4.3532\n",
      "Iteration: 112; Percent complete: 2.8%; Average loss: 4.6864\n",
      "Iteration: 113; Percent complete: 2.8%; Average loss: 4.4715\n",
      "Iteration: 114; Percent complete: 2.9%; Average loss: 4.3962\n",
      "Iteration: 115; Percent complete: 2.9%; Average loss: 4.4217\n",
      "Iteration: 116; Percent complete: 2.9%; Average loss: 4.3177\n",
      "Iteration: 117; Percent complete: 2.9%; Average loss: 4.2651\n",
      "Iteration: 118; Percent complete: 2.9%; Average loss: 4.3009\n",
      "Iteration: 119; Percent complete: 3.0%; Average loss: 4.3855\n",
      "Iteration: 120; Percent complete: 3.0%; Average loss: 4.4489\n",
      "Iteration: 121; Percent complete: 3.0%; Average loss: 4.1426\n",
      "Iteration: 122; Percent complete: 3.0%; Average loss: 4.2500\n",
      "Iteration: 123; Percent complete: 3.1%; Average loss: 4.1910\n",
      "Iteration: 124; Percent complete: 3.1%; Average loss: 4.2298\n",
      "Iteration: 125; Percent complete: 3.1%; Average loss: 4.4139\n",
      "Iteration: 126; Percent complete: 3.1%; Average loss: 4.3682\n",
      "Iteration: 127; Percent complete: 3.2%; Average loss: 4.1123\n",
      "Iteration: 128; Percent complete: 3.2%; Average loss: 4.1868\n",
      "Iteration: 129; Percent complete: 3.2%; Average loss: 4.5598\n",
      "Iteration: 130; Percent complete: 3.2%; Average loss: 4.4054\n",
      "Iteration: 131; Percent complete: 3.3%; Average loss: 4.1943\n",
      "Iteration: 132; Percent complete: 3.3%; Average loss: 4.3314\n",
      "Iteration: 133; Percent complete: 3.3%; Average loss: 4.3112\n",
      "Iteration: 134; Percent complete: 3.4%; Average loss: 4.3577\n",
      "Iteration: 135; Percent complete: 3.4%; Average loss: 4.3440\n",
      "Iteration: 136; Percent complete: 3.4%; Average loss: 4.2237\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 137; Percent complete: 3.4%; Average loss: 3.9428\n",
      "Iteration: 138; Percent complete: 3.5%; Average loss: 4.2595\n",
      "Iteration: 139; Percent complete: 3.5%; Average loss: 4.3676\n",
      "Iteration: 140; Percent complete: 3.5%; Average loss: 3.9856\n",
      "Iteration: 141; Percent complete: 3.5%; Average loss: 4.1910\n",
      "Iteration: 142; Percent complete: 3.5%; Average loss: 4.3608\n",
      "Iteration: 143; Percent complete: 3.6%; Average loss: 4.2609\n",
      "Iteration: 144; Percent complete: 3.6%; Average loss: 4.0666\n",
      "Iteration: 145; Percent complete: 3.6%; Average loss: 4.1462\n",
      "Iteration: 146; Percent complete: 3.6%; Average loss: 4.0375\n",
      "Iteration: 147; Percent complete: 3.7%; Average loss: 4.1463\n",
      "Iteration: 148; Percent complete: 3.7%; Average loss: 4.2465\n",
      "Iteration: 149; Percent complete: 3.7%; Average loss: 4.4061\n",
      "Iteration: 150; Percent complete: 3.8%; Average loss: 4.2570\n",
      "Iteration: 151; Percent complete: 3.8%; Average loss: 4.4216\n",
      "Iteration: 152; Percent complete: 3.8%; Average loss: 4.2867\n",
      "Iteration: 153; Percent complete: 3.8%; Average loss: 4.4098\n",
      "Iteration: 154; Percent complete: 3.9%; Average loss: 4.3501\n",
      "Iteration: 155; Percent complete: 3.9%; Average loss: 4.2850\n",
      "Iteration: 156; Percent complete: 3.9%; Average loss: 4.1582\n",
      "Iteration: 157; Percent complete: 3.9%; Average loss: 4.1809\n",
      "Iteration: 158; Percent complete: 4.0%; Average loss: 4.0056\n",
      "Iteration: 159; Percent complete: 4.0%; Average loss: 4.1179\n",
      "Iteration: 160; Percent complete: 4.0%; Average loss: 4.1659\n",
      "Iteration: 161; Percent complete: 4.0%; Average loss: 4.1286\n",
      "Iteration: 162; Percent complete: 4.0%; Average loss: 4.3399\n",
      "Iteration: 163; Percent complete: 4.1%; Average loss: 4.1864\n",
      "Iteration: 164; Percent complete: 4.1%; Average loss: 4.3171\n",
      "Iteration: 165; Percent complete: 4.1%; Average loss: 3.9673\n",
      "Iteration: 166; Percent complete: 4.2%; Average loss: 4.1444\n",
      "Iteration: 167; Percent complete: 4.2%; Average loss: 4.2847\n",
      "Iteration: 168; Percent complete: 4.2%; Average loss: 3.8897\n",
      "Iteration: 169; Percent complete: 4.2%; Average loss: 4.4558\n",
      "Iteration: 170; Percent complete: 4.2%; Average loss: 3.9455\n",
      "Iteration: 171; Percent complete: 4.3%; Average loss: 4.2130\n",
      "Iteration: 172; Percent complete: 4.3%; Average loss: 4.1869\n",
      "Iteration: 173; Percent complete: 4.3%; Average loss: 4.0512\n",
      "Iteration: 174; Percent complete: 4.3%; Average loss: 4.3263\n",
      "Iteration: 175; Percent complete: 4.4%; Average loss: 4.2542\n",
      "Iteration: 176; Percent complete: 4.4%; Average loss: 4.2431\n",
      "Iteration: 177; Percent complete: 4.4%; Average loss: 4.2422\n",
      "Iteration: 178; Percent complete: 4.5%; Average loss: 3.9539\n",
      "Iteration: 179; Percent complete: 4.5%; Average loss: 4.2604\n",
      "Iteration: 180; Percent complete: 4.5%; Average loss: 4.1240\n",
      "Iteration: 181; Percent complete: 4.5%; Average loss: 4.0207\n",
      "Iteration: 182; Percent complete: 4.5%; Average loss: 4.0677\n",
      "Iteration: 183; Percent complete: 4.6%; Average loss: 4.1213\n",
      "Iteration: 184; Percent complete: 4.6%; Average loss: 4.1560\n",
      "Iteration: 185; Percent complete: 4.6%; Average loss: 4.0495\n",
      "Iteration: 186; Percent complete: 4.7%; Average loss: 3.9758\n",
      "Iteration: 187; Percent complete: 4.7%; Average loss: 4.0056\n",
      "Iteration: 188; Percent complete: 4.7%; Average loss: 3.9499\n",
      "Iteration: 189; Percent complete: 4.7%; Average loss: 4.1876\n",
      "Iteration: 190; Percent complete: 4.8%; Average loss: 4.2698\n",
      "Iteration: 191; Percent complete: 4.8%; Average loss: 4.0239\n",
      "Iteration: 192; Percent complete: 4.8%; Average loss: 4.0177\n",
      "Iteration: 193; Percent complete: 4.8%; Average loss: 3.8626\n",
      "Iteration: 194; Percent complete: 4.9%; Average loss: 3.7571\n",
      "Iteration: 195; Percent complete: 4.9%; Average loss: 3.9166\n",
      "Iteration: 196; Percent complete: 4.9%; Average loss: 3.9268\n",
      "Iteration: 197; Percent complete: 4.9%; Average loss: 4.1184\n",
      "Iteration: 198; Percent complete: 5.0%; Average loss: 4.1471\n",
      "Iteration: 199; Percent complete: 5.0%; Average loss: 4.3376\n",
      "Iteration: 200; Percent complete: 5.0%; Average loss: 4.0780\n",
      "Iteration: 201; Percent complete: 5.0%; Average loss: 4.0900\n",
      "Iteration: 202; Percent complete: 5.1%; Average loss: 4.2691\n",
      "Iteration: 203; Percent complete: 5.1%; Average loss: 3.7334\n",
      "Iteration: 204; Percent complete: 5.1%; Average loss: 4.0948\n",
      "Iteration: 205; Percent complete: 5.1%; Average loss: 4.0077\n",
      "Iteration: 206; Percent complete: 5.1%; Average loss: 4.1744\n",
      "Iteration: 207; Percent complete: 5.2%; Average loss: 4.1546\n",
      "Iteration: 208; Percent complete: 5.2%; Average loss: 3.9550\n",
      "Iteration: 209; Percent complete: 5.2%; Average loss: 4.1147\n",
      "Iteration: 210; Percent complete: 5.2%; Average loss: 3.9075\n",
      "Iteration: 211; Percent complete: 5.3%; Average loss: 3.9762\n",
      "Iteration: 212; Percent complete: 5.3%; Average loss: 4.0271\n",
      "Iteration: 213; Percent complete: 5.3%; Average loss: 4.3487\n",
      "Iteration: 214; Percent complete: 5.3%; Average loss: 4.2909\n",
      "Iteration: 215; Percent complete: 5.4%; Average loss: 4.2654\n",
      "Iteration: 216; Percent complete: 5.4%; Average loss: 3.9544\n",
      "Iteration: 217; Percent complete: 5.4%; Average loss: 4.0117\n",
      "Iteration: 218; Percent complete: 5.5%; Average loss: 3.8433\n",
      "Iteration: 219; Percent complete: 5.5%; Average loss: 3.9701\n",
      "Iteration: 220; Percent complete: 5.5%; Average loss: 3.9985\n",
      "Iteration: 221; Percent complete: 5.5%; Average loss: 4.2146\n",
      "Iteration: 222; Percent complete: 5.5%; Average loss: 4.0178\n",
      "Iteration: 223; Percent complete: 5.6%; Average loss: 4.0074\n",
      "Iteration: 224; Percent complete: 5.6%; Average loss: 3.8309\n",
      "Iteration: 225; Percent complete: 5.6%; Average loss: 3.9340\n",
      "Iteration: 226; Percent complete: 5.7%; Average loss: 4.0104\n",
      "Iteration: 227; Percent complete: 5.7%; Average loss: 4.0583\n",
      "Iteration: 228; Percent complete: 5.7%; Average loss: 4.1168\n",
      "Iteration: 229; Percent complete: 5.7%; Average loss: 3.9607\n",
      "Iteration: 230; Percent complete: 5.8%; Average loss: 3.8406\n",
      "Iteration: 231; Percent complete: 5.8%; Average loss: 3.9416\n",
      "Iteration: 232; Percent complete: 5.8%; Average loss: 3.9497\n",
      "Iteration: 233; Percent complete: 5.8%; Average loss: 4.1020\n",
      "Iteration: 234; Percent complete: 5.9%; Average loss: 4.0101\n",
      "Iteration: 235; Percent complete: 5.9%; Average loss: 3.7778\n",
      "Iteration: 236; Percent complete: 5.9%; Average loss: 4.0592\n",
      "Iteration: 237; Percent complete: 5.9%; Average loss: 3.8092\n",
      "Iteration: 238; Percent complete: 5.9%; Average loss: 3.9038\n",
      "Iteration: 239; Percent complete: 6.0%; Average loss: 3.9484\n",
      "Iteration: 240; Percent complete: 6.0%; Average loss: 4.0996\n",
      "Iteration: 241; Percent complete: 6.0%; Average loss: 4.0271\n",
      "Iteration: 242; Percent complete: 6.0%; Average loss: 3.6844\n",
      "Iteration: 243; Percent complete: 6.1%; Average loss: 3.7260\n",
      "Iteration: 244; Percent complete: 6.1%; Average loss: 3.7078\n",
      "Iteration: 245; Percent complete: 6.1%; Average loss: 3.9366\n",
      "Iteration: 246; Percent complete: 6.2%; Average loss: 4.1104\n",
      "Iteration: 247; Percent complete: 6.2%; Average loss: 3.8965\n",
      "Iteration: 248; Percent complete: 6.2%; Average loss: 3.8277\n",
      "Iteration: 249; Percent complete: 6.2%; Average loss: 4.0895\n",
      "Iteration: 250; Percent complete: 6.2%; Average loss: 3.8378\n",
      "Iteration: 251; Percent complete: 6.3%; Average loss: 3.9059\n",
      "Iteration: 252; Percent complete: 6.3%; Average loss: 3.6686\n",
      "Iteration: 253; Percent complete: 6.3%; Average loss: 4.0286\n",
      "Iteration: 254; Percent complete: 6.3%; Average loss: 4.1367\n",
      "Iteration: 255; Percent complete: 6.4%; Average loss: 3.7354\n",
      "Iteration: 256; Percent complete: 6.4%; Average loss: 3.9829\n",
      "Iteration: 257; Percent complete: 6.4%; Average loss: 4.0283\n",
      "Iteration: 258; Percent complete: 6.5%; Average loss: 3.8936\n",
      "Iteration: 259; Percent complete: 6.5%; Average loss: 4.0744\n",
      "Iteration: 260; Percent complete: 6.5%; Average loss: 3.8202\n",
      "Iteration: 261; Percent complete: 6.5%; Average loss: 3.9201\n",
      "Iteration: 262; Percent complete: 6.6%; Average loss: 4.1789\n",
      "Iteration: 263; Percent complete: 6.6%; Average loss: 3.9947\n",
      "Iteration: 264; Percent complete: 6.6%; Average loss: 3.8359\n",
      "Iteration: 265; Percent complete: 6.6%; Average loss: 3.8444\n",
      "Iteration: 266; Percent complete: 6.7%; Average loss: 4.1318\n",
      "Iteration: 267; Percent complete: 6.7%; Average loss: 4.2687\n",
      "Iteration: 268; Percent complete: 6.7%; Average loss: 3.9356\n",
      "Iteration: 269; Percent complete: 6.7%; Average loss: 4.1795\n",
      "Iteration: 270; Percent complete: 6.8%; Average loss: 3.7358\n",
      "Iteration: 271; Percent complete: 6.8%; Average loss: 4.1940\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 272; Percent complete: 6.8%; Average loss: 4.2116\n",
      "Iteration: 273; Percent complete: 6.8%; Average loss: 3.7408\n",
      "Iteration: 274; Percent complete: 6.9%; Average loss: 3.8164\n",
      "Iteration: 275; Percent complete: 6.9%; Average loss: 3.8470\n",
      "Iteration: 276; Percent complete: 6.9%; Average loss: 4.0231\n",
      "Iteration: 277; Percent complete: 6.9%; Average loss: 3.9050\n",
      "Iteration: 278; Percent complete: 7.0%; Average loss: 3.7214\n",
      "Iteration: 279; Percent complete: 7.0%; Average loss: 4.0905\n",
      "Iteration: 280; Percent complete: 7.0%; Average loss: 3.5992\n",
      "Iteration: 281; Percent complete: 7.0%; Average loss: 3.9087\n",
      "Iteration: 282; Percent complete: 7.0%; Average loss: 3.8199\n",
      "Iteration: 283; Percent complete: 7.1%; Average loss: 4.3843\n",
      "Iteration: 284; Percent complete: 7.1%; Average loss: 3.7915\n",
      "Iteration: 285; Percent complete: 7.1%; Average loss: 4.3710\n",
      "Iteration: 286; Percent complete: 7.1%; Average loss: 4.0898\n",
      "Iteration: 287; Percent complete: 7.2%; Average loss: 3.8006\n",
      "Iteration: 288; Percent complete: 7.2%; Average loss: 4.0609\n",
      "Iteration: 289; Percent complete: 7.2%; Average loss: 3.9538\n",
      "Iteration: 290; Percent complete: 7.2%; Average loss: 3.9493\n",
      "Iteration: 291; Percent complete: 7.3%; Average loss: 3.9710\n",
      "Iteration: 292; Percent complete: 7.3%; Average loss: 4.0796\n",
      "Iteration: 293; Percent complete: 7.3%; Average loss: 3.9514\n",
      "Iteration: 294; Percent complete: 7.3%; Average loss: 4.3282\n",
      "Iteration: 295; Percent complete: 7.4%; Average loss: 3.9546\n",
      "Iteration: 296; Percent complete: 7.4%; Average loss: 4.1774\n",
      "Iteration: 297; Percent complete: 7.4%; Average loss: 3.9485\n",
      "Iteration: 298; Percent complete: 7.4%; Average loss: 3.8305\n",
      "Iteration: 299; Percent complete: 7.5%; Average loss: 3.7502\n",
      "Iteration: 300; Percent complete: 7.5%; Average loss: 3.8814\n",
      "Iteration: 301; Percent complete: 7.5%; Average loss: 4.0918\n",
      "Iteration: 302; Percent complete: 7.5%; Average loss: 4.0494\n",
      "Iteration: 303; Percent complete: 7.6%; Average loss: 4.0668\n",
      "Iteration: 304; Percent complete: 7.6%; Average loss: 3.9601\n",
      "Iteration: 305; Percent complete: 7.6%; Average loss: 4.1665\n",
      "Iteration: 306; Percent complete: 7.6%; Average loss: 3.7597\n",
      "Iteration: 307; Percent complete: 7.7%; Average loss: 3.9615\n",
      "Iteration: 308; Percent complete: 7.7%; Average loss: 3.8869\n",
      "Iteration: 309; Percent complete: 7.7%; Average loss: 3.6327\n",
      "Iteration: 310; Percent complete: 7.8%; Average loss: 3.7673\n",
      "Iteration: 311; Percent complete: 7.8%; Average loss: 3.7887\n",
      "Iteration: 312; Percent complete: 7.8%; Average loss: 3.8527\n",
      "Iteration: 313; Percent complete: 7.8%; Average loss: 3.8516\n",
      "Iteration: 314; Percent complete: 7.8%; Average loss: 3.7585\n",
      "Iteration: 315; Percent complete: 7.9%; Average loss: 4.1852\n",
      "Iteration: 316; Percent complete: 7.9%; Average loss: 3.9033\n",
      "Iteration: 317; Percent complete: 7.9%; Average loss: 3.9694\n",
      "Iteration: 318; Percent complete: 8.0%; Average loss: 3.7593\n",
      "Iteration: 319; Percent complete: 8.0%; Average loss: 3.7806\n",
      "Iteration: 320; Percent complete: 8.0%; Average loss: 3.7100\n",
      "Iteration: 321; Percent complete: 8.0%; Average loss: 4.1992\n",
      "Iteration: 322; Percent complete: 8.1%; Average loss: 3.9917\n",
      "Iteration: 323; Percent complete: 8.1%; Average loss: 3.8464\n",
      "Iteration: 324; Percent complete: 8.1%; Average loss: 3.7436\n",
      "Iteration: 325; Percent complete: 8.1%; Average loss: 3.9938\n",
      "Iteration: 326; Percent complete: 8.2%; Average loss: 4.0989\n",
      "Iteration: 327; Percent complete: 8.2%; Average loss: 3.8906\n",
      "Iteration: 328; Percent complete: 8.2%; Average loss: 3.9842\n",
      "Iteration: 329; Percent complete: 8.2%; Average loss: 4.4472\n",
      "Iteration: 330; Percent complete: 8.2%; Average loss: 4.1662\n",
      "Iteration: 331; Percent complete: 8.3%; Average loss: 3.9431\n",
      "Iteration: 332; Percent complete: 8.3%; Average loss: 3.7381\n",
      "Iteration: 333; Percent complete: 8.3%; Average loss: 3.6730\n",
      "Iteration: 334; Percent complete: 8.3%; Average loss: 3.6378\n",
      "Iteration: 335; Percent complete: 8.4%; Average loss: 4.0537\n",
      "Iteration: 336; Percent complete: 8.4%; Average loss: 3.8071\n",
      "Iteration: 337; Percent complete: 8.4%; Average loss: 4.0824\n",
      "Iteration: 338; Percent complete: 8.5%; Average loss: 4.0343\n",
      "Iteration: 339; Percent complete: 8.5%; Average loss: 3.7550\n",
      "Iteration: 340; Percent complete: 8.5%; Average loss: 4.0386\n",
      "Iteration: 341; Percent complete: 8.5%; Average loss: 4.0263\n",
      "Iteration: 342; Percent complete: 8.6%; Average loss: 3.9204\n",
      "Iteration: 343; Percent complete: 8.6%; Average loss: 3.7898\n",
      "Iteration: 344; Percent complete: 8.6%; Average loss: 4.0119\n",
      "Iteration: 345; Percent complete: 8.6%; Average loss: 3.8368\n",
      "Iteration: 346; Percent complete: 8.6%; Average loss: 3.8862\n",
      "Iteration: 347; Percent complete: 8.7%; Average loss: 3.6199\n",
      "Iteration: 348; Percent complete: 8.7%; Average loss: 3.7596\n",
      "Iteration: 349; Percent complete: 8.7%; Average loss: 3.8610\n",
      "Iteration: 350; Percent complete: 8.8%; Average loss: 3.5332\n",
      "Iteration: 351; Percent complete: 8.8%; Average loss: 4.0111\n",
      "Iteration: 352; Percent complete: 8.8%; Average loss: 3.7925\n",
      "Iteration: 353; Percent complete: 8.8%; Average loss: 3.6736\n",
      "Iteration: 354; Percent complete: 8.8%; Average loss: 4.0376\n",
      "Iteration: 355; Percent complete: 8.9%; Average loss: 3.8425\n",
      "Iteration: 356; Percent complete: 8.9%; Average loss: 3.6773\n",
      "Iteration: 357; Percent complete: 8.9%; Average loss: 3.7262\n",
      "Iteration: 358; Percent complete: 8.9%; Average loss: 3.9001\n",
      "Iteration: 359; Percent complete: 9.0%; Average loss: 3.7829\n",
      "Iteration: 360; Percent complete: 9.0%; Average loss: 3.9164\n",
      "Iteration: 361; Percent complete: 9.0%; Average loss: 3.7051\n",
      "Iteration: 362; Percent complete: 9.0%; Average loss: 3.7312\n",
      "Iteration: 363; Percent complete: 9.1%; Average loss: 3.7305\n",
      "Iteration: 364; Percent complete: 9.1%; Average loss: 3.9673\n",
      "Iteration: 365; Percent complete: 9.1%; Average loss: 3.7029\n",
      "Iteration: 366; Percent complete: 9.2%; Average loss: 3.9756\n",
      "Iteration: 367; Percent complete: 9.2%; Average loss: 3.6799\n",
      "Iteration: 368; Percent complete: 9.2%; Average loss: 3.9364\n",
      "Iteration: 369; Percent complete: 9.2%; Average loss: 4.0251\n",
      "Iteration: 370; Percent complete: 9.2%; Average loss: 3.7847\n",
      "Iteration: 371; Percent complete: 9.3%; Average loss: 4.0141\n",
      "Iteration: 372; Percent complete: 9.3%; Average loss: 3.9887\n",
      "Iteration: 373; Percent complete: 9.3%; Average loss: 3.9996\n",
      "Iteration: 374; Percent complete: 9.3%; Average loss: 3.8587\n",
      "Iteration: 375; Percent complete: 9.4%; Average loss: 3.9852\n",
      "Iteration: 376; Percent complete: 9.4%; Average loss: 3.7643\n",
      "Iteration: 377; Percent complete: 9.4%; Average loss: 4.1306\n",
      "Iteration: 378; Percent complete: 9.4%; Average loss: 3.8235\n",
      "Iteration: 379; Percent complete: 9.5%; Average loss: 3.9616\n",
      "Iteration: 380; Percent complete: 9.5%; Average loss: 3.7498\n",
      "Iteration: 381; Percent complete: 9.5%; Average loss: 3.9076\n",
      "Iteration: 382; Percent complete: 9.6%; Average loss: 3.8799\n",
      "Iteration: 383; Percent complete: 9.6%; Average loss: 3.8665\n",
      "Iteration: 384; Percent complete: 9.6%; Average loss: 3.8878\n",
      "Iteration: 385; Percent complete: 9.6%; Average loss: 3.6357\n",
      "Iteration: 386; Percent complete: 9.7%; Average loss: 4.0989\n",
      "Iteration: 387; Percent complete: 9.7%; Average loss: 3.7793\n",
      "Iteration: 388; Percent complete: 9.7%; Average loss: 3.7809\n",
      "Iteration: 389; Percent complete: 9.7%; Average loss: 3.7542\n",
      "Iteration: 390; Percent complete: 9.8%; Average loss: 3.8728\n",
      "Iteration: 391; Percent complete: 9.8%; Average loss: 3.9635\n",
      "Iteration: 392; Percent complete: 9.8%; Average loss: 3.7595\n",
      "Iteration: 393; Percent complete: 9.8%; Average loss: 3.8374\n",
      "Iteration: 394; Percent complete: 9.8%; Average loss: 3.8012\n",
      "Iteration: 395; Percent complete: 9.9%; Average loss: 3.5185\n",
      "Iteration: 396; Percent complete: 9.9%; Average loss: 3.6594\n",
      "Iteration: 397; Percent complete: 9.9%; Average loss: 3.9626\n",
      "Iteration: 398; Percent complete: 10.0%; Average loss: 3.9323\n",
      "Iteration: 399; Percent complete: 10.0%; Average loss: 3.7620\n",
      "Iteration: 400; Percent complete: 10.0%; Average loss: 3.8561\n",
      "Iteration: 401; Percent complete: 10.0%; Average loss: 3.9257\n",
      "Iteration: 402; Percent complete: 10.1%; Average loss: 3.6651\n",
      "Iteration: 403; Percent complete: 10.1%; Average loss: 3.6006\n",
      "Iteration: 404; Percent complete: 10.1%; Average loss: 3.5749\n",
      "Iteration: 405; Percent complete: 10.1%; Average loss: 3.6149\n",
      "Iteration: 406; Percent complete: 10.2%; Average loss: 3.9099\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 407; Percent complete: 10.2%; Average loss: 3.8712\n",
      "Iteration: 408; Percent complete: 10.2%; Average loss: 3.8327\n",
      "Iteration: 409; Percent complete: 10.2%; Average loss: 3.9890\n",
      "Iteration: 410; Percent complete: 10.2%; Average loss: 3.5614\n",
      "Iteration: 411; Percent complete: 10.3%; Average loss: 3.6177\n",
      "Iteration: 412; Percent complete: 10.3%; Average loss: 3.7443\n",
      "Iteration: 413; Percent complete: 10.3%; Average loss: 3.8454\n",
      "Iteration: 414; Percent complete: 10.3%; Average loss: 4.0110\n",
      "Iteration: 415; Percent complete: 10.4%; Average loss: 3.6697\n",
      "Iteration: 416; Percent complete: 10.4%; Average loss: 3.9002\n",
      "Iteration: 417; Percent complete: 10.4%; Average loss: 4.0055\n",
      "Iteration: 418; Percent complete: 10.4%; Average loss: 3.8575\n",
      "Iteration: 419; Percent complete: 10.5%; Average loss: 4.0350\n",
      "Iteration: 420; Percent complete: 10.5%; Average loss: 3.5256\n",
      "Iteration: 421; Percent complete: 10.5%; Average loss: 3.5741\n",
      "Iteration: 422; Percent complete: 10.5%; Average loss: 3.6380\n",
      "Iteration: 423; Percent complete: 10.6%; Average loss: 3.9840\n",
      "Iteration: 424; Percent complete: 10.6%; Average loss: 3.8204\n",
      "Iteration: 425; Percent complete: 10.6%; Average loss: 3.7883\n",
      "Iteration: 426; Percent complete: 10.7%; Average loss: 3.7226\n",
      "Iteration: 427; Percent complete: 10.7%; Average loss: 3.6087\n",
      "Iteration: 428; Percent complete: 10.7%; Average loss: 3.6874\n",
      "Iteration: 429; Percent complete: 10.7%; Average loss: 4.0539\n",
      "Iteration: 430; Percent complete: 10.8%; Average loss: 3.5672\n",
      "Iteration: 431; Percent complete: 10.8%; Average loss: 3.8803\n",
      "Iteration: 432; Percent complete: 10.8%; Average loss: 3.6655\n",
      "Iteration: 433; Percent complete: 10.8%; Average loss: 3.8427\n",
      "Iteration: 434; Percent complete: 10.8%; Average loss: 3.7154\n",
      "Iteration: 435; Percent complete: 10.9%; Average loss: 3.6089\n",
      "Iteration: 436; Percent complete: 10.9%; Average loss: 3.6506\n",
      "Iteration: 437; Percent complete: 10.9%; Average loss: 3.6082\n",
      "Iteration: 438; Percent complete: 10.9%; Average loss: 3.7703\n",
      "Iteration: 439; Percent complete: 11.0%; Average loss: 3.7334\n",
      "Iteration: 440; Percent complete: 11.0%; Average loss: 3.8843\n",
      "Iteration: 441; Percent complete: 11.0%; Average loss: 3.4026\n",
      "Iteration: 442; Percent complete: 11.1%; Average loss: 3.8481\n",
      "Iteration: 443; Percent complete: 11.1%; Average loss: 3.9222\n",
      "Iteration: 444; Percent complete: 11.1%; Average loss: 3.5709\n",
      "Iteration: 445; Percent complete: 11.1%; Average loss: 3.7149\n",
      "Iteration: 446; Percent complete: 11.2%; Average loss: 3.7970\n",
      "Iteration: 447; Percent complete: 11.2%; Average loss: 3.6280\n",
      "Iteration: 448; Percent complete: 11.2%; Average loss: 3.7221\n",
      "Iteration: 449; Percent complete: 11.2%; Average loss: 3.7513\n",
      "Iteration: 450; Percent complete: 11.2%; Average loss: 3.5549\n",
      "Iteration: 451; Percent complete: 11.3%; Average loss: 3.9426\n",
      "Iteration: 452; Percent complete: 11.3%; Average loss: 3.6648\n",
      "Iteration: 453; Percent complete: 11.3%; Average loss: 3.8276\n",
      "Iteration: 454; Percent complete: 11.3%; Average loss: 3.6974\n",
      "Iteration: 455; Percent complete: 11.4%; Average loss: 4.0087\n",
      "Iteration: 456; Percent complete: 11.4%; Average loss: 3.7283\n",
      "Iteration: 457; Percent complete: 11.4%; Average loss: 4.0697\n",
      "Iteration: 458; Percent complete: 11.5%; Average loss: 3.5790\n",
      "Iteration: 459; Percent complete: 11.5%; Average loss: 3.6102\n",
      "Iteration: 460; Percent complete: 11.5%; Average loss: 3.5056\n",
      "Iteration: 461; Percent complete: 11.5%; Average loss: 3.9545\n",
      "Iteration: 462; Percent complete: 11.6%; Average loss: 3.5173\n",
      "Iteration: 463; Percent complete: 11.6%; Average loss: 3.8122\n",
      "Iteration: 464; Percent complete: 11.6%; Average loss: 3.6748\n",
      "Iteration: 465; Percent complete: 11.6%; Average loss: 3.5644\n",
      "Iteration: 466; Percent complete: 11.7%; Average loss: 3.6500\n",
      "Iteration: 467; Percent complete: 11.7%; Average loss: 3.8697\n",
      "Iteration: 468; Percent complete: 11.7%; Average loss: 3.9584\n",
      "Iteration: 469; Percent complete: 11.7%; Average loss: 3.9297\n",
      "Iteration: 470; Percent complete: 11.8%; Average loss: 3.7858\n",
      "Iteration: 471; Percent complete: 11.8%; Average loss: 3.7467\n",
      "Iteration: 472; Percent complete: 11.8%; Average loss: 3.7608\n",
      "Iteration: 473; Percent complete: 11.8%; Average loss: 3.8565\n",
      "Iteration: 474; Percent complete: 11.8%; Average loss: 3.8993\n",
      "Iteration: 475; Percent complete: 11.9%; Average loss: 3.7739\n",
      "Iteration: 476; Percent complete: 11.9%; Average loss: 3.8743\n",
      "Iteration: 477; Percent complete: 11.9%; Average loss: 3.5536\n",
      "Iteration: 478; Percent complete: 11.9%; Average loss: 3.7054\n",
      "Iteration: 479; Percent complete: 12.0%; Average loss: 3.5366\n",
      "Iteration: 480; Percent complete: 12.0%; Average loss: 3.8077\n",
      "Iteration: 481; Percent complete: 12.0%; Average loss: 3.9446\n",
      "Iteration: 482; Percent complete: 12.0%; Average loss: 3.4708\n",
      "Iteration: 483; Percent complete: 12.1%; Average loss: 3.8681\n",
      "Iteration: 484; Percent complete: 12.1%; Average loss: 3.9638\n",
      "Iteration: 485; Percent complete: 12.1%; Average loss: 3.4278\n",
      "Iteration: 486; Percent complete: 12.2%; Average loss: 3.6056\n",
      "Iteration: 487; Percent complete: 12.2%; Average loss: 3.7130\n",
      "Iteration: 488; Percent complete: 12.2%; Average loss: 3.6386\n",
      "Iteration: 489; Percent complete: 12.2%; Average loss: 3.7005\n",
      "Iteration: 490; Percent complete: 12.2%; Average loss: 3.6635\n",
      "Iteration: 491; Percent complete: 12.3%; Average loss: 4.0287\n",
      "Iteration: 492; Percent complete: 12.3%; Average loss: 3.9369\n",
      "Iteration: 493; Percent complete: 12.3%; Average loss: 3.7971\n",
      "Iteration: 494; Percent complete: 12.3%; Average loss: 3.7748\n",
      "Iteration: 495; Percent complete: 12.4%; Average loss: 3.7570\n",
      "Iteration: 496; Percent complete: 12.4%; Average loss: 3.8068\n",
      "Iteration: 497; Percent complete: 12.4%; Average loss: 3.6709\n",
      "Iteration: 498; Percent complete: 12.4%; Average loss: 3.7387\n",
      "Iteration: 499; Percent complete: 12.5%; Average loss: 3.5959\n",
      "Iteration: 500; Percent complete: 12.5%; Average loss: 3.7015\n",
      "Iteration: 501; Percent complete: 12.5%; Average loss: 3.7421\n",
      "Iteration: 502; Percent complete: 12.6%; Average loss: 3.6759\n",
      "Iteration: 503; Percent complete: 12.6%; Average loss: 3.5665\n",
      "Iteration: 504; Percent complete: 12.6%; Average loss: 3.8070\n",
      "Iteration: 505; Percent complete: 12.6%; Average loss: 3.4960\n",
      "Iteration: 506; Percent complete: 12.7%; Average loss: 4.0291\n",
      "Iteration: 507; Percent complete: 12.7%; Average loss: 3.6138\n",
      "Iteration: 508; Percent complete: 12.7%; Average loss: 3.5767\n",
      "Iteration: 509; Percent complete: 12.7%; Average loss: 3.5687\n",
      "Iteration: 510; Percent complete: 12.8%; Average loss: 3.4782\n",
      "Iteration: 511; Percent complete: 12.8%; Average loss: 3.9328\n",
      "Iteration: 512; Percent complete: 12.8%; Average loss: 3.5055\n",
      "Iteration: 513; Percent complete: 12.8%; Average loss: 3.4203\n",
      "Iteration: 514; Percent complete: 12.8%; Average loss: 3.4748\n",
      "Iteration: 515; Percent complete: 12.9%; Average loss: 3.6738\n",
      "Iteration: 516; Percent complete: 12.9%; Average loss: 3.5069\n",
      "Iteration: 517; Percent complete: 12.9%; Average loss: 3.7096\n",
      "Iteration: 518; Percent complete: 13.0%; Average loss: 3.9377\n",
      "Iteration: 519; Percent complete: 13.0%; Average loss: 4.0859\n",
      "Iteration: 520; Percent complete: 13.0%; Average loss: 3.8474\n",
      "Iteration: 521; Percent complete: 13.0%; Average loss: 3.7283\n",
      "Iteration: 522; Percent complete: 13.1%; Average loss: 3.5065\n",
      "Iteration: 523; Percent complete: 13.1%; Average loss: 3.6762\n",
      "Iteration: 524; Percent complete: 13.1%; Average loss: 3.7056\n",
      "Iteration: 525; Percent complete: 13.1%; Average loss: 3.8386\n",
      "Iteration: 526; Percent complete: 13.2%; Average loss: 3.4262\n",
      "Iteration: 527; Percent complete: 13.2%; Average loss: 3.5460\n",
      "Iteration: 528; Percent complete: 13.2%; Average loss: 3.5368\n",
      "Iteration: 529; Percent complete: 13.2%; Average loss: 3.7320\n",
      "Iteration: 530; Percent complete: 13.2%; Average loss: 3.8674\n",
      "Iteration: 531; Percent complete: 13.3%; Average loss: 3.5885\n",
      "Iteration: 532; Percent complete: 13.3%; Average loss: 3.9190\n",
      "Iteration: 533; Percent complete: 13.3%; Average loss: 3.7180\n",
      "Iteration: 534; Percent complete: 13.4%; Average loss: 3.7668\n",
      "Iteration: 535; Percent complete: 13.4%; Average loss: 3.6042\n",
      "Iteration: 536; Percent complete: 13.4%; Average loss: 3.7866\n",
      "Iteration: 537; Percent complete: 13.4%; Average loss: 3.6418\n",
      "Iteration: 538; Percent complete: 13.5%; Average loss: 3.8672\n",
      "Iteration: 539; Percent complete: 13.5%; Average loss: 3.8029\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 540; Percent complete: 13.5%; Average loss: 3.7628\n",
      "Iteration: 541; Percent complete: 13.5%; Average loss: 3.8208\n",
      "Iteration: 542; Percent complete: 13.6%; Average loss: 3.7936\n",
      "Iteration: 543; Percent complete: 13.6%; Average loss: 3.7270\n",
      "Iteration: 544; Percent complete: 13.6%; Average loss: 3.6580\n",
      "Iteration: 545; Percent complete: 13.6%; Average loss: 3.7961\n",
      "Iteration: 546; Percent complete: 13.7%; Average loss: 3.6821\n",
      "Iteration: 547; Percent complete: 13.7%; Average loss: 3.8556\n",
      "Iteration: 548; Percent complete: 13.7%; Average loss: 3.4883\n",
      "Iteration: 549; Percent complete: 13.7%; Average loss: 3.5885\n",
      "Iteration: 550; Percent complete: 13.8%; Average loss: 3.6899\n",
      "Iteration: 551; Percent complete: 13.8%; Average loss: 3.9822\n",
      "Iteration: 552; Percent complete: 13.8%; Average loss: 3.7055\n",
      "Iteration: 553; Percent complete: 13.8%; Average loss: 3.8179\n",
      "Iteration: 554; Percent complete: 13.9%; Average loss: 3.8998\n",
      "Iteration: 555; Percent complete: 13.9%; Average loss: 3.8589\n",
      "Iteration: 556; Percent complete: 13.9%; Average loss: 3.5978\n",
      "Iteration: 557; Percent complete: 13.9%; Average loss: 3.8420\n",
      "Iteration: 558; Percent complete: 14.0%; Average loss: 3.6764\n",
      "Iteration: 559; Percent complete: 14.0%; Average loss: 3.8502\n",
      "Iteration: 560; Percent complete: 14.0%; Average loss: 3.6679\n",
      "Iteration: 561; Percent complete: 14.0%; Average loss: 3.7158\n",
      "Iteration: 562; Percent complete: 14.1%; Average loss: 3.8035\n",
      "Iteration: 563; Percent complete: 14.1%; Average loss: 3.5510\n",
      "Iteration: 564; Percent complete: 14.1%; Average loss: 3.4537\n",
      "Iteration: 565; Percent complete: 14.1%; Average loss: 3.4138\n",
      "Iteration: 566; Percent complete: 14.1%; Average loss: 3.6991\n",
      "Iteration: 567; Percent complete: 14.2%; Average loss: 3.5220\n",
      "Iteration: 568; Percent complete: 14.2%; Average loss: 3.4218\n",
      "Iteration: 569; Percent complete: 14.2%; Average loss: 3.6990\n",
      "Iteration: 570; Percent complete: 14.2%; Average loss: 3.8327\n",
      "Iteration: 571; Percent complete: 14.3%; Average loss: 3.5619\n",
      "Iteration: 572; Percent complete: 14.3%; Average loss: 3.6782\n",
      "Iteration: 573; Percent complete: 14.3%; Average loss: 3.5074\n",
      "Iteration: 574; Percent complete: 14.3%; Average loss: 3.6227\n",
      "Iteration: 575; Percent complete: 14.4%; Average loss: 3.2142\n",
      "Iteration: 576; Percent complete: 14.4%; Average loss: 3.9579\n",
      "Iteration: 577; Percent complete: 14.4%; Average loss: 3.6213\n",
      "Iteration: 578; Percent complete: 14.4%; Average loss: 3.5753\n",
      "Iteration: 579; Percent complete: 14.5%; Average loss: 3.8308\n",
      "Iteration: 580; Percent complete: 14.5%; Average loss: 3.9896\n",
      "Iteration: 581; Percent complete: 14.5%; Average loss: 3.4769\n",
      "Iteration: 582; Percent complete: 14.5%; Average loss: 3.7635\n",
      "Iteration: 583; Percent complete: 14.6%; Average loss: 3.8037\n",
      "Iteration: 584; Percent complete: 14.6%; Average loss: 3.5523\n",
      "Iteration: 585; Percent complete: 14.6%; Average loss: 3.7365\n",
      "Iteration: 586; Percent complete: 14.6%; Average loss: 3.7648\n",
      "Iteration: 587; Percent complete: 14.7%; Average loss: 3.8929\n",
      "Iteration: 588; Percent complete: 14.7%; Average loss: 3.8225\n",
      "Iteration: 589; Percent complete: 14.7%; Average loss: 3.6973\n",
      "Iteration: 590; Percent complete: 14.8%; Average loss: 3.9917\n",
      "Iteration: 591; Percent complete: 14.8%; Average loss: 3.6687\n",
      "Iteration: 592; Percent complete: 14.8%; Average loss: 3.6974\n",
      "Iteration: 593; Percent complete: 14.8%; Average loss: 3.5036\n",
      "Iteration: 594; Percent complete: 14.8%; Average loss: 3.7737\n",
      "Iteration: 595; Percent complete: 14.9%; Average loss: 3.9453\n",
      "Iteration: 596; Percent complete: 14.9%; Average loss: 3.7344\n",
      "Iteration: 597; Percent complete: 14.9%; Average loss: 3.8288\n",
      "Iteration: 598; Percent complete: 14.9%; Average loss: 3.6648\n",
      "Iteration: 599; Percent complete: 15.0%; Average loss: 3.7468\n",
      "Iteration: 600; Percent complete: 15.0%; Average loss: 3.6735\n",
      "Iteration: 601; Percent complete: 15.0%; Average loss: 3.5276\n",
      "Iteration: 602; Percent complete: 15.0%; Average loss: 3.7899\n",
      "Iteration: 603; Percent complete: 15.1%; Average loss: 3.6551\n",
      "Iteration: 604; Percent complete: 15.1%; Average loss: 3.7318\n",
      "Iteration: 605; Percent complete: 15.1%; Average loss: 3.6654\n",
      "Iteration: 606; Percent complete: 15.2%; Average loss: 3.7998\n",
      "Iteration: 607; Percent complete: 15.2%; Average loss: 3.7843\n",
      "Iteration: 608; Percent complete: 15.2%; Average loss: 3.5559\n",
      "Iteration: 609; Percent complete: 15.2%; Average loss: 3.5818\n",
      "Iteration: 610; Percent complete: 15.2%; Average loss: 3.4985\n",
      "Iteration: 611; Percent complete: 15.3%; Average loss: 3.6050\n",
      "Iteration: 612; Percent complete: 15.3%; Average loss: 3.4841\n",
      "Iteration: 613; Percent complete: 15.3%; Average loss: 3.4399\n",
      "Iteration: 614; Percent complete: 15.3%; Average loss: 3.6910\n",
      "Iteration: 615; Percent complete: 15.4%; Average loss: 3.8162\n",
      "Iteration: 616; Percent complete: 15.4%; Average loss: 4.0030\n",
      "Iteration: 617; Percent complete: 15.4%; Average loss: 3.7661\n",
      "Iteration: 618; Percent complete: 15.4%; Average loss: 3.7102\n",
      "Iteration: 619; Percent complete: 15.5%; Average loss: 3.7345\n",
      "Iteration: 620; Percent complete: 15.5%; Average loss: 3.3927\n",
      "Iteration: 621; Percent complete: 15.5%; Average loss: 3.5844\n",
      "Iteration: 622; Percent complete: 15.6%; Average loss: 3.4869\n",
      "Iteration: 623; Percent complete: 15.6%; Average loss: 3.6874\n",
      "Iteration: 624; Percent complete: 15.6%; Average loss: 3.8652\n",
      "Iteration: 625; Percent complete: 15.6%; Average loss: 3.7887\n",
      "Iteration: 626; Percent complete: 15.7%; Average loss: 3.5468\n",
      "Iteration: 627; Percent complete: 15.7%; Average loss: 3.6825\n",
      "Iteration: 628; Percent complete: 15.7%; Average loss: 3.6897\n",
      "Iteration: 629; Percent complete: 15.7%; Average loss: 3.6451\n",
      "Iteration: 630; Percent complete: 15.8%; Average loss: 3.8138\n",
      "Iteration: 631; Percent complete: 15.8%; Average loss: 3.6413\n",
      "Iteration: 632; Percent complete: 15.8%; Average loss: 3.5543\n",
      "Iteration: 633; Percent complete: 15.8%; Average loss: 3.6318\n",
      "Iteration: 634; Percent complete: 15.8%; Average loss: 3.7148\n",
      "Iteration: 635; Percent complete: 15.9%; Average loss: 3.6022\n",
      "Iteration: 636; Percent complete: 15.9%; Average loss: 3.4981\n",
      "Iteration: 637; Percent complete: 15.9%; Average loss: 3.6769\n",
      "Iteration: 638; Percent complete: 16.0%; Average loss: 3.5713\n",
      "Iteration: 639; Percent complete: 16.0%; Average loss: 3.4043\n",
      "Iteration: 640; Percent complete: 16.0%; Average loss: 3.6479\n",
      "Iteration: 641; Percent complete: 16.0%; Average loss: 3.4076\n",
      "Iteration: 642; Percent complete: 16.1%; Average loss: 3.5778\n",
      "Iteration: 643; Percent complete: 16.1%; Average loss: 3.6375\n",
      "Iteration: 644; Percent complete: 16.1%; Average loss: 3.8422\n",
      "Iteration: 645; Percent complete: 16.1%; Average loss: 3.5555\n",
      "Iteration: 646; Percent complete: 16.2%; Average loss: 3.6828\n",
      "Iteration: 647; Percent complete: 16.2%; Average loss: 3.4532\n",
      "Iteration: 648; Percent complete: 16.2%; Average loss: 3.8342\n",
      "Iteration: 649; Percent complete: 16.2%; Average loss: 3.3274\n",
      "Iteration: 650; Percent complete: 16.2%; Average loss: 3.6757\n",
      "Iteration: 651; Percent complete: 16.3%; Average loss: 3.5450\n",
      "Iteration: 652; Percent complete: 16.3%; Average loss: 3.8049\n",
      "Iteration: 653; Percent complete: 16.3%; Average loss: 3.6527\n",
      "Iteration: 654; Percent complete: 16.4%; Average loss: 3.4650\n",
      "Iteration: 655; Percent complete: 16.4%; Average loss: 3.7276\n",
      "Iteration: 656; Percent complete: 16.4%; Average loss: 3.6521\n",
      "Iteration: 657; Percent complete: 16.4%; Average loss: 3.5656\n",
      "Iteration: 658; Percent complete: 16.4%; Average loss: 3.4562\n",
      "Iteration: 659; Percent complete: 16.5%; Average loss: 3.7507\n",
      "Iteration: 660; Percent complete: 16.5%; Average loss: 3.3423\n",
      "Iteration: 661; Percent complete: 16.5%; Average loss: 3.7733\n",
      "Iteration: 662; Percent complete: 16.6%; Average loss: 3.5655\n",
      "Iteration: 663; Percent complete: 16.6%; Average loss: 3.5542\n",
      "Iteration: 664; Percent complete: 16.6%; Average loss: 3.5403\n",
      "Iteration: 665; Percent complete: 16.6%; Average loss: 3.5269\n",
      "Iteration: 666; Percent complete: 16.7%; Average loss: 3.6442\n",
      "Iteration: 667; Percent complete: 16.7%; Average loss: 3.6557\n",
      "Iteration: 668; Percent complete: 16.7%; Average loss: 3.6950\n",
      "Iteration: 669; Percent complete: 16.7%; Average loss: 3.5301\n",
      "Iteration: 670; Percent complete: 16.8%; Average loss: 3.5287\n",
      "Iteration: 671; Percent complete: 16.8%; Average loss: 3.8131\n",
      "Iteration: 672; Percent complete: 16.8%; Average loss: 3.4859\n",
      "Iteration: 673; Percent complete: 16.8%; Average loss: 3.4931\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 674; Percent complete: 16.9%; Average loss: 3.5931\n",
      "Iteration: 675; Percent complete: 16.9%; Average loss: 3.6442\n",
      "Iteration: 676; Percent complete: 16.9%; Average loss: 3.5300\n",
      "Iteration: 677; Percent complete: 16.9%; Average loss: 3.7174\n",
      "Iteration: 678; Percent complete: 17.0%; Average loss: 3.6628\n",
      "Iteration: 679; Percent complete: 17.0%; Average loss: 3.8659\n",
      "Iteration: 680; Percent complete: 17.0%; Average loss: 3.4715\n",
      "Iteration: 681; Percent complete: 17.0%; Average loss: 3.7139\n",
      "Iteration: 682; Percent complete: 17.1%; Average loss: 3.6874\n",
      "Iteration: 683; Percent complete: 17.1%; Average loss: 3.4318\n",
      "Iteration: 684; Percent complete: 17.1%; Average loss: 3.5946\n",
      "Iteration: 685; Percent complete: 17.1%; Average loss: 3.3479\n",
      "Iteration: 686; Percent complete: 17.2%; Average loss: 3.3753\n",
      "Iteration: 687; Percent complete: 17.2%; Average loss: 3.4991\n",
      "Iteration: 688; Percent complete: 17.2%; Average loss: 3.9536\n",
      "Iteration: 689; Percent complete: 17.2%; Average loss: 3.9378\n",
      "Iteration: 690; Percent complete: 17.2%; Average loss: 3.8148\n",
      "Iteration: 691; Percent complete: 17.3%; Average loss: 3.7135\n",
      "Iteration: 692; Percent complete: 17.3%; Average loss: 3.6428\n",
      "Iteration: 693; Percent complete: 17.3%; Average loss: 3.2727\n",
      "Iteration: 694; Percent complete: 17.3%; Average loss: 3.7644\n",
      "Iteration: 695; Percent complete: 17.4%; Average loss: 3.8152\n",
      "Iteration: 696; Percent complete: 17.4%; Average loss: 3.5578\n",
      "Iteration: 697; Percent complete: 17.4%; Average loss: 3.6849\n",
      "Iteration: 698; Percent complete: 17.4%; Average loss: 3.5479\n",
      "Iteration: 699; Percent complete: 17.5%; Average loss: 3.7578\n",
      "Iteration: 700; Percent complete: 17.5%; Average loss: 3.3104\n",
      "Iteration: 701; Percent complete: 17.5%; Average loss: 3.5606\n",
      "Iteration: 702; Percent complete: 17.5%; Average loss: 3.5326\n",
      "Iteration: 703; Percent complete: 17.6%; Average loss: 3.5178\n",
      "Iteration: 704; Percent complete: 17.6%; Average loss: 3.2010\n",
      "Iteration: 705; Percent complete: 17.6%; Average loss: 3.6406\n",
      "Iteration: 706; Percent complete: 17.6%; Average loss: 3.4612\n",
      "Iteration: 707; Percent complete: 17.7%; Average loss: 3.4896\n",
      "Iteration: 708; Percent complete: 17.7%; Average loss: 3.5960\n",
      "Iteration: 709; Percent complete: 17.7%; Average loss: 3.5881\n",
      "Iteration: 710; Percent complete: 17.8%; Average loss: 3.4656\n",
      "Iteration: 711; Percent complete: 17.8%; Average loss: 3.1679\n",
      "Iteration: 712; Percent complete: 17.8%; Average loss: 3.8744\n",
      "Iteration: 713; Percent complete: 17.8%; Average loss: 3.7908\n",
      "Iteration: 714; Percent complete: 17.8%; Average loss: 3.4273\n",
      "Iteration: 715; Percent complete: 17.9%; Average loss: 3.6432\n",
      "Iteration: 716; Percent complete: 17.9%; Average loss: 3.5519\n",
      "Iteration: 717; Percent complete: 17.9%; Average loss: 3.5935\n",
      "Iteration: 718; Percent complete: 17.9%; Average loss: 3.5642\n",
      "Iteration: 719; Percent complete: 18.0%; Average loss: 3.2455\n",
      "Iteration: 720; Percent complete: 18.0%; Average loss: 3.5071\n",
      "Iteration: 721; Percent complete: 18.0%; Average loss: 3.5913\n",
      "Iteration: 722; Percent complete: 18.1%; Average loss: 3.4608\n",
      "Iteration: 723; Percent complete: 18.1%; Average loss: 3.4313\n",
      "Iteration: 724; Percent complete: 18.1%; Average loss: 3.7963\n",
      "Iteration: 725; Percent complete: 18.1%; Average loss: 3.3050\n",
      "Iteration: 726; Percent complete: 18.1%; Average loss: 3.7923\n",
      "Iteration: 727; Percent complete: 18.2%; Average loss: 3.4984\n",
      "Iteration: 728; Percent complete: 18.2%; Average loss: 3.5170\n",
      "Iteration: 729; Percent complete: 18.2%; Average loss: 3.5270\n",
      "Iteration: 730; Percent complete: 18.2%; Average loss: 3.7359\n",
      "Iteration: 731; Percent complete: 18.3%; Average loss: 3.4966\n",
      "Iteration: 732; Percent complete: 18.3%; Average loss: 3.6040\n",
      "Iteration: 733; Percent complete: 18.3%; Average loss: 3.4852\n",
      "Iteration: 734; Percent complete: 18.4%; Average loss: 3.6445\n",
      "Iteration: 735; Percent complete: 18.4%; Average loss: 3.8302\n",
      "Iteration: 736; Percent complete: 18.4%; Average loss: 3.3293\n",
      "Iteration: 737; Percent complete: 18.4%; Average loss: 3.6468\n",
      "Iteration: 738; Percent complete: 18.4%; Average loss: 3.6003\n",
      "Iteration: 739; Percent complete: 18.5%; Average loss: 3.5877\n",
      "Iteration: 740; Percent complete: 18.5%; Average loss: 3.5294\n",
      "Iteration: 741; Percent complete: 18.5%; Average loss: 3.8556\n",
      "Iteration: 742; Percent complete: 18.6%; Average loss: 3.4054\n",
      "Iteration: 743; Percent complete: 18.6%; Average loss: 3.6440\n",
      "Iteration: 744; Percent complete: 18.6%; Average loss: 3.4399\n",
      "Iteration: 745; Percent complete: 18.6%; Average loss: 3.5441\n",
      "Iteration: 746; Percent complete: 18.6%; Average loss: 3.6704\n",
      "Iteration: 747; Percent complete: 18.7%; Average loss: 3.6376\n",
      "Iteration: 748; Percent complete: 18.7%; Average loss: 3.5928\n",
      "Iteration: 749; Percent complete: 18.7%; Average loss: 3.8563\n",
      "Iteration: 750; Percent complete: 18.8%; Average loss: 3.6866\n",
      "Iteration: 751; Percent complete: 18.8%; Average loss: 3.3690\n",
      "Iteration: 752; Percent complete: 18.8%; Average loss: 3.5373\n",
      "Iteration: 753; Percent complete: 18.8%; Average loss: 3.4130\n",
      "Iteration: 754; Percent complete: 18.9%; Average loss: 3.4341\n",
      "Iteration: 755; Percent complete: 18.9%; Average loss: 3.4411\n",
      "Iteration: 756; Percent complete: 18.9%; Average loss: 3.7764\n",
      "Iteration: 757; Percent complete: 18.9%; Average loss: 3.5071\n",
      "Iteration: 758; Percent complete: 18.9%; Average loss: 3.4095\n",
      "Iteration: 759; Percent complete: 19.0%; Average loss: 3.6235\n",
      "Iteration: 760; Percent complete: 19.0%; Average loss: 3.7059\n",
      "Iteration: 761; Percent complete: 19.0%; Average loss: 3.4804\n",
      "Iteration: 762; Percent complete: 19.1%; Average loss: 3.4071\n",
      "Iteration: 763; Percent complete: 19.1%; Average loss: 3.3777\n",
      "Iteration: 764; Percent complete: 19.1%; Average loss: 3.7662\n",
      "Iteration: 765; Percent complete: 19.1%; Average loss: 3.3955\n",
      "Iteration: 766; Percent complete: 19.1%; Average loss: 3.4404\n",
      "Iteration: 767; Percent complete: 19.2%; Average loss: 3.6324\n",
      "Iteration: 768; Percent complete: 19.2%; Average loss: 3.7649\n",
      "Iteration: 769; Percent complete: 19.2%; Average loss: 3.4708\n",
      "Iteration: 770; Percent complete: 19.2%; Average loss: 3.6598\n",
      "Iteration: 771; Percent complete: 19.3%; Average loss: 3.4354\n",
      "Iteration: 772; Percent complete: 19.3%; Average loss: 3.3997\n",
      "Iteration: 773; Percent complete: 19.3%; Average loss: 3.5783\n",
      "Iteration: 774; Percent complete: 19.4%; Average loss: 3.2422\n",
      "Iteration: 775; Percent complete: 19.4%; Average loss: 3.2921\n",
      "Iteration: 776; Percent complete: 19.4%; Average loss: 3.5678\n",
      "Iteration: 777; Percent complete: 19.4%; Average loss: 3.4509\n",
      "Iteration: 778; Percent complete: 19.4%; Average loss: 3.6675\n",
      "Iteration: 779; Percent complete: 19.5%; Average loss: 3.6300\n",
      "Iteration: 780; Percent complete: 19.5%; Average loss: 3.6115\n",
      "Iteration: 781; Percent complete: 19.5%; Average loss: 3.2259\n",
      "Iteration: 782; Percent complete: 19.6%; Average loss: 3.5440\n",
      "Iteration: 783; Percent complete: 19.6%; Average loss: 3.6300\n",
      "Iteration: 784; Percent complete: 19.6%; Average loss: 3.3282\n",
      "Iteration: 785; Percent complete: 19.6%; Average loss: 3.6166\n",
      "Iteration: 786; Percent complete: 19.7%; Average loss: 3.3081\n",
      "Iteration: 787; Percent complete: 19.7%; Average loss: 3.6024\n",
      "Iteration: 788; Percent complete: 19.7%; Average loss: 3.3420\n",
      "Iteration: 789; Percent complete: 19.7%; Average loss: 3.2792\n",
      "Iteration: 790; Percent complete: 19.8%; Average loss: 3.4544\n",
      "Iteration: 791; Percent complete: 19.8%; Average loss: 3.5563\n",
      "Iteration: 792; Percent complete: 19.8%; Average loss: 3.4469\n",
      "Iteration: 793; Percent complete: 19.8%; Average loss: 3.6497\n",
      "Iteration: 794; Percent complete: 19.9%; Average loss: 3.5767\n",
      "Iteration: 795; Percent complete: 19.9%; Average loss: 3.6948\n",
      "Iteration: 796; Percent complete: 19.9%; Average loss: 3.5327\n",
      "Iteration: 797; Percent complete: 19.9%; Average loss: 3.5864\n",
      "Iteration: 798; Percent complete: 20.0%; Average loss: 3.3454\n",
      "Iteration: 799; Percent complete: 20.0%; Average loss: 3.3074\n",
      "Iteration: 800; Percent complete: 20.0%; Average loss: 3.5840\n",
      "Iteration: 801; Percent complete: 20.0%; Average loss: 3.6544\n",
      "Iteration: 802; Percent complete: 20.1%; Average loss: 3.5542\n",
      "Iteration: 803; Percent complete: 20.1%; Average loss: 3.4012\n",
      "Iteration: 804; Percent complete: 20.1%; Average loss: 3.6838\n",
      "Iteration: 805; Percent complete: 20.1%; Average loss: 3.1733\n",
      "Iteration: 806; Percent complete: 20.2%; Average loss: 3.5359\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 807; Percent complete: 20.2%; Average loss: 3.3861\n",
      "Iteration: 808; Percent complete: 20.2%; Average loss: 3.6940\n",
      "Iteration: 809; Percent complete: 20.2%; Average loss: 3.2631\n",
      "Iteration: 810; Percent complete: 20.2%; Average loss: 3.5310\n",
      "Iteration: 811; Percent complete: 20.3%; Average loss: 3.6475\n",
      "Iteration: 812; Percent complete: 20.3%; Average loss: 3.4716\n",
      "Iteration: 813; Percent complete: 20.3%; Average loss: 3.6221\n",
      "Iteration: 814; Percent complete: 20.3%; Average loss: 3.6793\n",
      "Iteration: 815; Percent complete: 20.4%; Average loss: 3.3777\n",
      "Iteration: 816; Percent complete: 20.4%; Average loss: 3.4151\n",
      "Iteration: 817; Percent complete: 20.4%; Average loss: 3.3355\n",
      "Iteration: 818; Percent complete: 20.4%; Average loss: 3.3661\n",
      "Iteration: 819; Percent complete: 20.5%; Average loss: 3.6611\n",
      "Iteration: 820; Percent complete: 20.5%; Average loss: 3.6677\n",
      "Iteration: 821; Percent complete: 20.5%; Average loss: 3.3445\n",
      "Iteration: 822; Percent complete: 20.5%; Average loss: 3.6654\n",
      "Iteration: 823; Percent complete: 20.6%; Average loss: 3.4636\n",
      "Iteration: 824; Percent complete: 20.6%; Average loss: 3.5874\n",
      "Iteration: 825; Percent complete: 20.6%; Average loss: 3.3731\n",
      "Iteration: 826; Percent complete: 20.6%; Average loss: 3.6648\n",
      "Iteration: 827; Percent complete: 20.7%; Average loss: 3.4329\n",
      "Iteration: 828; Percent complete: 20.7%; Average loss: 3.2580\n",
      "Iteration: 829; Percent complete: 20.7%; Average loss: 3.4907\n",
      "Iteration: 830; Percent complete: 20.8%; Average loss: 3.7521\n",
      "Iteration: 831; Percent complete: 20.8%; Average loss: 3.4762\n",
      "Iteration: 832; Percent complete: 20.8%; Average loss: 3.6147\n",
      "Iteration: 833; Percent complete: 20.8%; Average loss: 3.6619\n",
      "Iteration: 834; Percent complete: 20.8%; Average loss: 3.8147\n",
      "Iteration: 835; Percent complete: 20.9%; Average loss: 3.9700\n",
      "Iteration: 836; Percent complete: 20.9%; Average loss: 3.4645\n",
      "Iteration: 837; Percent complete: 20.9%; Average loss: 3.4789\n",
      "Iteration: 838; Percent complete: 20.9%; Average loss: 4.0085\n",
      "Iteration: 839; Percent complete: 21.0%; Average loss: 3.6878\n",
      "Iteration: 840; Percent complete: 21.0%; Average loss: 3.5020\n",
      "Iteration: 841; Percent complete: 21.0%; Average loss: 3.5703\n",
      "Iteration: 842; Percent complete: 21.1%; Average loss: 3.4200\n",
      "Iteration: 843; Percent complete: 21.1%; Average loss: 3.4041\n",
      "Iteration: 844; Percent complete: 21.1%; Average loss: 3.7036\n",
      "Iteration: 845; Percent complete: 21.1%; Average loss: 3.3305\n",
      "Iteration: 846; Percent complete: 21.1%; Average loss: 3.7422\n",
      "Iteration: 847; Percent complete: 21.2%; Average loss: 3.6027\n",
      "Iteration: 848; Percent complete: 21.2%; Average loss: 3.5922\n",
      "Iteration: 849; Percent complete: 21.2%; Average loss: 3.4427\n",
      "Iteration: 850; Percent complete: 21.2%; Average loss: 3.6936\n",
      "Iteration: 851; Percent complete: 21.3%; Average loss: 3.7948\n",
      "Iteration: 852; Percent complete: 21.3%; Average loss: 3.3955\n",
      "Iteration: 853; Percent complete: 21.3%; Average loss: 3.4581\n",
      "Iteration: 854; Percent complete: 21.3%; Average loss: 3.7273\n",
      "Iteration: 855; Percent complete: 21.4%; Average loss: 3.4164\n",
      "Iteration: 856; Percent complete: 21.4%; Average loss: 3.4791\n",
      "Iteration: 857; Percent complete: 21.4%; Average loss: 3.6305\n",
      "Iteration: 858; Percent complete: 21.4%; Average loss: 3.3469\n",
      "Iteration: 859; Percent complete: 21.5%; Average loss: 3.2508\n",
      "Iteration: 860; Percent complete: 21.5%; Average loss: 3.6129\n",
      "Iteration: 861; Percent complete: 21.5%; Average loss: 3.4083\n",
      "Iteration: 862; Percent complete: 21.6%; Average loss: 3.6047\n",
      "Iteration: 863; Percent complete: 21.6%; Average loss: 3.6340\n",
      "Iteration: 864; Percent complete: 21.6%; Average loss: 3.7971\n",
      "Iteration: 865; Percent complete: 21.6%; Average loss: 3.5151\n",
      "Iteration: 866; Percent complete: 21.6%; Average loss: 3.6364\n",
      "Iteration: 867; Percent complete: 21.7%; Average loss: 3.2734\n",
      "Iteration: 868; Percent complete: 21.7%; Average loss: 3.5880\n",
      "Iteration: 869; Percent complete: 21.7%; Average loss: 3.7003\n",
      "Iteration: 870; Percent complete: 21.8%; Average loss: 3.4258\n",
      "Iteration: 871; Percent complete: 21.8%; Average loss: 3.3149\n",
      "Iteration: 872; Percent complete: 21.8%; Average loss: 3.3390\n",
      "Iteration: 873; Percent complete: 21.8%; Average loss: 3.4242\n",
      "Iteration: 874; Percent complete: 21.9%; Average loss: 3.1862\n",
      "Iteration: 875; Percent complete: 21.9%; Average loss: 3.6180\n",
      "Iteration: 876; Percent complete: 21.9%; Average loss: 3.2549\n",
      "Iteration: 877; Percent complete: 21.9%; Average loss: 3.3915\n",
      "Iteration: 878; Percent complete: 21.9%; Average loss: 3.2100\n",
      "Iteration: 879; Percent complete: 22.0%; Average loss: 3.6705\n",
      "Iteration: 880; Percent complete: 22.0%; Average loss: 3.8244\n",
      "Iteration: 881; Percent complete: 22.0%; Average loss: 3.4692\n",
      "Iteration: 882; Percent complete: 22.1%; Average loss: 3.5247\n",
      "Iteration: 883; Percent complete: 22.1%; Average loss: 3.4066\n",
      "Iteration: 884; Percent complete: 22.1%; Average loss: 3.6360\n",
      "Iteration: 885; Percent complete: 22.1%; Average loss: 3.5448\n",
      "Iteration: 886; Percent complete: 22.1%; Average loss: 3.4848\n",
      "Iteration: 887; Percent complete: 22.2%; Average loss: 3.5981\n",
      "Iteration: 888; Percent complete: 22.2%; Average loss: 3.6582\n",
      "Iteration: 889; Percent complete: 22.2%; Average loss: 3.1964\n",
      "Iteration: 890; Percent complete: 22.2%; Average loss: 3.4437\n",
      "Iteration: 891; Percent complete: 22.3%; Average loss: 3.5178\n",
      "Iteration: 892; Percent complete: 22.3%; Average loss: 3.6038\n",
      "Iteration: 893; Percent complete: 22.3%; Average loss: 3.3579\n",
      "Iteration: 894; Percent complete: 22.4%; Average loss: 3.4853\n",
      "Iteration: 895; Percent complete: 22.4%; Average loss: 3.5643\n",
      "Iteration: 896; Percent complete: 22.4%; Average loss: 3.5601\n",
      "Iteration: 897; Percent complete: 22.4%; Average loss: 3.4334\n",
      "Iteration: 898; Percent complete: 22.4%; Average loss: 3.3159\n",
      "Iteration: 899; Percent complete: 22.5%; Average loss: 3.2943\n",
      "Iteration: 900; Percent complete: 22.5%; Average loss: 3.5241\n",
      "Iteration: 901; Percent complete: 22.5%; Average loss: 3.7586\n",
      "Iteration: 902; Percent complete: 22.6%; Average loss: 3.4478\n",
      "Iteration: 903; Percent complete: 22.6%; Average loss: 3.4657\n",
      "Iteration: 904; Percent complete: 22.6%; Average loss: 3.3616\n",
      "Iteration: 905; Percent complete: 22.6%; Average loss: 3.7302\n",
      "Iteration: 906; Percent complete: 22.7%; Average loss: 3.4241\n",
      "Iteration: 907; Percent complete: 22.7%; Average loss: 3.5984\n",
      "Iteration: 908; Percent complete: 22.7%; Average loss: 3.2153\n",
      "Iteration: 909; Percent complete: 22.7%; Average loss: 3.4380\n",
      "Iteration: 910; Percent complete: 22.8%; Average loss: 3.4675\n",
      "Iteration: 911; Percent complete: 22.8%; Average loss: 3.4549\n",
      "Iteration: 912; Percent complete: 22.8%; Average loss: 3.4007\n",
      "Iteration: 913; Percent complete: 22.8%; Average loss: 3.4776\n",
      "Iteration: 914; Percent complete: 22.9%; Average loss: 3.6318\n",
      "Iteration: 915; Percent complete: 22.9%; Average loss: 3.3586\n",
      "Iteration: 916; Percent complete: 22.9%; Average loss: 3.2951\n",
      "Iteration: 917; Percent complete: 22.9%; Average loss: 3.4178\n",
      "Iteration: 918; Percent complete: 22.9%; Average loss: 3.6297\n",
      "Iteration: 919; Percent complete: 23.0%; Average loss: 3.2722\n",
      "Iteration: 920; Percent complete: 23.0%; Average loss: 3.9252\n",
      "Iteration: 921; Percent complete: 23.0%; Average loss: 3.5450\n",
      "Iteration: 922; Percent complete: 23.1%; Average loss: 3.4403\n",
      "Iteration: 923; Percent complete: 23.1%; Average loss: 3.4108\n",
      "Iteration: 924; Percent complete: 23.1%; Average loss: 3.6791\n",
      "Iteration: 925; Percent complete: 23.1%; Average loss: 3.5527\n",
      "Iteration: 926; Percent complete: 23.2%; Average loss: 3.6385\n",
      "Iteration: 927; Percent complete: 23.2%; Average loss: 3.2380\n",
      "Iteration: 928; Percent complete: 23.2%; Average loss: 3.3297\n",
      "Iteration: 929; Percent complete: 23.2%; Average loss: 3.6686\n",
      "Iteration: 930; Percent complete: 23.2%; Average loss: 3.5201\n",
      "Iteration: 931; Percent complete: 23.3%; Average loss: 3.6340\n",
      "Iteration: 932; Percent complete: 23.3%; Average loss: 3.2521\n",
      "Iteration: 933; Percent complete: 23.3%; Average loss: 3.4147\n",
      "Iteration: 934; Percent complete: 23.4%; Average loss: 3.5626\n",
      "Iteration: 935; Percent complete: 23.4%; Average loss: 3.4645\n",
      "Iteration: 936; Percent complete: 23.4%; Average loss: 3.2628\n",
      "Iteration: 937; Percent complete: 23.4%; Average loss: 3.7647\n",
      "Iteration: 938; Percent complete: 23.4%; Average loss: 3.3781\n",
      "Iteration: 939; Percent complete: 23.5%; Average loss: 3.6768\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 940; Percent complete: 23.5%; Average loss: 3.5972\n",
      "Iteration: 941; Percent complete: 23.5%; Average loss: 3.5709\n",
      "Iteration: 942; Percent complete: 23.5%; Average loss: 3.4461\n",
      "Iteration: 943; Percent complete: 23.6%; Average loss: 3.6590\n",
      "Iteration: 944; Percent complete: 23.6%; Average loss: 3.4368\n",
      "Iteration: 945; Percent complete: 23.6%; Average loss: 3.5546\n",
      "Iteration: 946; Percent complete: 23.6%; Average loss: 3.6241\n",
      "Iteration: 947; Percent complete: 23.7%; Average loss: 3.6113\n",
      "Iteration: 948; Percent complete: 23.7%; Average loss: 3.6235\n",
      "Iteration: 949; Percent complete: 23.7%; Average loss: 3.2878\n",
      "Iteration: 950; Percent complete: 23.8%; Average loss: 3.2076\n",
      "Iteration: 951; Percent complete: 23.8%; Average loss: 3.3823\n",
      "Iteration: 952; Percent complete: 23.8%; Average loss: 3.8505\n",
      "Iteration: 953; Percent complete: 23.8%; Average loss: 3.4697\n",
      "Iteration: 954; Percent complete: 23.8%; Average loss: 3.6281\n",
      "Iteration: 955; Percent complete: 23.9%; Average loss: 3.5401\n",
      "Iteration: 956; Percent complete: 23.9%; Average loss: 3.6461\n",
      "Iteration: 957; Percent complete: 23.9%; Average loss: 3.5922\n",
      "Iteration: 958; Percent complete: 23.9%; Average loss: 3.4572\n",
      "Iteration: 959; Percent complete: 24.0%; Average loss: 3.4061\n",
      "Iteration: 960; Percent complete: 24.0%; Average loss: 3.5940\n",
      "Iteration: 961; Percent complete: 24.0%; Average loss: 3.5477\n",
      "Iteration: 962; Percent complete: 24.1%; Average loss: 3.3969\n",
      "Iteration: 963; Percent complete: 24.1%; Average loss: 3.4829\n",
      "Iteration: 964; Percent complete: 24.1%; Average loss: 3.4236\n",
      "Iteration: 965; Percent complete: 24.1%; Average loss: 3.4864\n",
      "Iteration: 966; Percent complete: 24.1%; Average loss: 3.5509\n",
      "Iteration: 967; Percent complete: 24.2%; Average loss: 3.4995\n",
      "Iteration: 968; Percent complete: 24.2%; Average loss: 3.3654\n",
      "Iteration: 969; Percent complete: 24.2%; Average loss: 3.4759\n",
      "Iteration: 970; Percent complete: 24.2%; Average loss: 3.4118\n",
      "Iteration: 971; Percent complete: 24.3%; Average loss: 3.5774\n",
      "Iteration: 972; Percent complete: 24.3%; Average loss: 3.3683\n",
      "Iteration: 973; Percent complete: 24.3%; Average loss: 3.4757\n",
      "Iteration: 974; Percent complete: 24.3%; Average loss: 3.4637\n",
      "Iteration: 975; Percent complete: 24.4%; Average loss: 3.3481\n",
      "Iteration: 976; Percent complete: 24.4%; Average loss: 3.2881\n",
      "Iteration: 977; Percent complete: 24.4%; Average loss: 3.6125\n",
      "Iteration: 978; Percent complete: 24.4%; Average loss: 3.6454\n",
      "Iteration: 979; Percent complete: 24.5%; Average loss: 3.5980\n",
      "Iteration: 980; Percent complete: 24.5%; Average loss: 3.3869\n",
      "Iteration: 981; Percent complete: 24.5%; Average loss: 3.3038\n",
      "Iteration: 982; Percent complete: 24.6%; Average loss: 3.2342\n",
      "Iteration: 983; Percent complete: 24.6%; Average loss: 3.5189\n",
      "Iteration: 984; Percent complete: 24.6%; Average loss: 3.2657\n",
      "Iteration: 985; Percent complete: 24.6%; Average loss: 3.5170\n",
      "Iteration: 986; Percent complete: 24.6%; Average loss: 3.3058\n",
      "Iteration: 987; Percent complete: 24.7%; Average loss: 3.5216\n",
      "Iteration: 988; Percent complete: 24.7%; Average loss: 3.8034\n",
      "Iteration: 989; Percent complete: 24.7%; Average loss: 3.3927\n",
      "Iteration: 990; Percent complete: 24.8%; Average loss: 3.2919\n",
      "Iteration: 991; Percent complete: 24.8%; Average loss: 3.3174\n",
      "Iteration: 992; Percent complete: 24.8%; Average loss: 3.3802\n",
      "Iteration: 993; Percent complete: 24.8%; Average loss: 3.2560\n",
      "Iteration: 994; Percent complete: 24.9%; Average loss: 3.5862\n",
      "Iteration: 995; Percent complete: 24.9%; Average loss: 3.5035\n",
      "Iteration: 996; Percent complete: 24.9%; Average loss: 3.1656\n",
      "Iteration: 997; Percent complete: 24.9%; Average loss: 3.4877\n",
      "Iteration: 998; Percent complete: 24.9%; Average loss: 3.2778\n",
      "Iteration: 999; Percent complete: 25.0%; Average loss: 3.5306\n",
      "Iteration: 1000; Percent complete: 25.0%; Average loss: 3.4547\n",
      "Iteration: 1001; Percent complete: 25.0%; Average loss: 3.6367\n",
      "Iteration: 1002; Percent complete: 25.1%; Average loss: 3.5415\n",
      "Iteration: 1003; Percent complete: 25.1%; Average loss: 3.4522\n",
      "Iteration: 1004; Percent complete: 25.1%; Average loss: 3.4806\n",
      "Iteration: 1005; Percent complete: 25.1%; Average loss: 3.5163\n",
      "Iteration: 1006; Percent complete: 25.1%; Average loss: 3.3140\n",
      "Iteration: 1007; Percent complete: 25.2%; Average loss: 3.4689\n",
      "Iteration: 1008; Percent complete: 25.2%; Average loss: 3.1986\n",
      "Iteration: 1009; Percent complete: 25.2%; Average loss: 3.6934\n",
      "Iteration: 1010; Percent complete: 25.2%; Average loss: 3.6143\n",
      "Iteration: 1011; Percent complete: 25.3%; Average loss: 3.4472\n",
      "Iteration: 1012; Percent complete: 25.3%; Average loss: 3.4199\n",
      "Iteration: 1013; Percent complete: 25.3%; Average loss: 3.4373\n",
      "Iteration: 1014; Percent complete: 25.4%; Average loss: 3.5141\n",
      "Iteration: 1015; Percent complete: 25.4%; Average loss: 3.6158\n",
      "Iteration: 1016; Percent complete: 25.4%; Average loss: 3.4185\n",
      "Iteration: 1017; Percent complete: 25.4%; Average loss: 3.5105\n",
      "Iteration: 1018; Percent complete: 25.4%; Average loss: 3.3690\n",
      "Iteration: 1019; Percent complete: 25.5%; Average loss: 3.2863\n",
      "Iteration: 1020; Percent complete: 25.5%; Average loss: 3.4302\n",
      "Iteration: 1021; Percent complete: 25.5%; Average loss: 3.6028\n",
      "Iteration: 1022; Percent complete: 25.6%; Average loss: 3.4337\n",
      "Iteration: 1023; Percent complete: 25.6%; Average loss: 3.6638\n",
      "Iteration: 1024; Percent complete: 25.6%; Average loss: 3.6044\n",
      "Iteration: 1025; Percent complete: 25.6%; Average loss: 3.4356\n",
      "Iteration: 1026; Percent complete: 25.7%; Average loss: 3.3086\n",
      "Iteration: 1027; Percent complete: 25.7%; Average loss: 3.3909\n",
      "Iteration: 1028; Percent complete: 25.7%; Average loss: 3.5343\n",
      "Iteration: 1029; Percent complete: 25.7%; Average loss: 3.5107\n",
      "Iteration: 1030; Percent complete: 25.8%; Average loss: 3.4761\n",
      "Iteration: 1031; Percent complete: 25.8%; Average loss: 3.5012\n",
      "Iteration: 1032; Percent complete: 25.8%; Average loss: 3.4945\n",
      "Iteration: 1033; Percent complete: 25.8%; Average loss: 3.2967\n",
      "Iteration: 1034; Percent complete: 25.9%; Average loss: 3.7917\n",
      "Iteration: 1035; Percent complete: 25.9%; Average loss: 3.5098\n",
      "Iteration: 1036; Percent complete: 25.9%; Average loss: 3.7897\n",
      "Iteration: 1037; Percent complete: 25.9%; Average loss: 3.3756\n",
      "Iteration: 1038; Percent complete: 25.9%; Average loss: 3.4455\n",
      "Iteration: 1039; Percent complete: 26.0%; Average loss: 3.5137\n",
      "Iteration: 1040; Percent complete: 26.0%; Average loss: 3.4240\n",
      "Iteration: 1041; Percent complete: 26.0%; Average loss: 3.4816\n",
      "Iteration: 1042; Percent complete: 26.1%; Average loss: 3.4652\n",
      "Iteration: 1043; Percent complete: 26.1%; Average loss: 3.1764\n",
      "Iteration: 1044; Percent complete: 26.1%; Average loss: 3.6377\n",
      "Iteration: 1045; Percent complete: 26.1%; Average loss: 3.4586\n",
      "Iteration: 1046; Percent complete: 26.2%; Average loss: 3.6158\n",
      "Iteration: 1047; Percent complete: 26.2%; Average loss: 3.2285\n",
      "Iteration: 1048; Percent complete: 26.2%; Average loss: 3.2783\n",
      "Iteration: 1049; Percent complete: 26.2%; Average loss: 3.3927\n",
      "Iteration: 1050; Percent complete: 26.2%; Average loss: 3.4296\n",
      "Iteration: 1051; Percent complete: 26.3%; Average loss: 3.5702\n",
      "Iteration: 1052; Percent complete: 26.3%; Average loss: 3.6040\n",
      "Iteration: 1053; Percent complete: 26.3%; Average loss: 3.0801\n",
      "Iteration: 1054; Percent complete: 26.4%; Average loss: 3.3597\n",
      "Iteration: 1055; Percent complete: 26.4%; Average loss: 3.4712\n",
      "Iteration: 1056; Percent complete: 26.4%; Average loss: 3.6650\n",
      "Iteration: 1057; Percent complete: 26.4%; Average loss: 3.5954\n",
      "Iteration: 1058; Percent complete: 26.5%; Average loss: 3.5282\n",
      "Iteration: 1059; Percent complete: 26.5%; Average loss: 3.5856\n",
      "Iteration: 1060; Percent complete: 26.5%; Average loss: 3.4558\n",
      "Iteration: 1061; Percent complete: 26.5%; Average loss: 3.7131\n",
      "Iteration: 1062; Percent complete: 26.6%; Average loss: 3.3416\n",
      "Iteration: 1063; Percent complete: 26.6%; Average loss: 3.4040\n",
      "Iteration: 1064; Percent complete: 26.6%; Average loss: 3.3069\n",
      "Iteration: 1065; Percent complete: 26.6%; Average loss: 3.4988\n",
      "Iteration: 1066; Percent complete: 26.7%; Average loss: 3.4327\n",
      "Iteration: 1067; Percent complete: 26.7%; Average loss: 3.6053\n",
      "Iteration: 1068; Percent complete: 26.7%; Average loss: 3.2591\n",
      "Iteration: 1069; Percent complete: 26.7%; Average loss: 3.4837\n",
      "Iteration: 1070; Percent complete: 26.8%; Average loss: 3.4874\n",
      "Iteration: 1071; Percent complete: 26.8%; Average loss: 3.5326\n",
      "Iteration: 1072; Percent complete: 26.8%; Average loss: 3.5340\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 1073; Percent complete: 26.8%; Average loss: 3.5995\n",
      "Iteration: 1074; Percent complete: 26.9%; Average loss: 3.3236\n",
      "Iteration: 1075; Percent complete: 26.9%; Average loss: 3.1389\n",
      "Iteration: 1076; Percent complete: 26.9%; Average loss: 3.4097\n",
      "Iteration: 1077; Percent complete: 26.9%; Average loss: 3.2954\n",
      "Iteration: 1078; Percent complete: 27.0%; Average loss: 3.5159\n",
      "Iteration: 1079; Percent complete: 27.0%; Average loss: 3.2580\n",
      "Iteration: 1080; Percent complete: 27.0%; Average loss: 3.3785\n",
      "Iteration: 1081; Percent complete: 27.0%; Average loss: 3.3941\n",
      "Iteration: 1082; Percent complete: 27.1%; Average loss: 3.4267\n",
      "Iteration: 1083; Percent complete: 27.1%; Average loss: 3.2406\n",
      "Iteration: 1084; Percent complete: 27.1%; Average loss: 3.7950\n",
      "Iteration: 1085; Percent complete: 27.1%; Average loss: 3.4172\n",
      "Iteration: 1086; Percent complete: 27.2%; Average loss: 3.5816\n",
      "Iteration: 1087; Percent complete: 27.2%; Average loss: 3.3316\n",
      "Iteration: 1088; Percent complete: 27.2%; Average loss: 3.5455\n",
      "Iteration: 1089; Percent complete: 27.2%; Average loss: 3.6612\n",
      "Iteration: 1090; Percent complete: 27.3%; Average loss: 3.3648\n",
      "Iteration: 1091; Percent complete: 27.3%; Average loss: 3.6471\n",
      "Iteration: 1092; Percent complete: 27.3%; Average loss: 3.4755\n",
      "Iteration: 1093; Percent complete: 27.3%; Average loss: 3.5203\n",
      "Iteration: 1094; Percent complete: 27.4%; Average loss: 3.4260\n",
      "Iteration: 1095; Percent complete: 27.4%; Average loss: 3.6122\n",
      "Iteration: 1096; Percent complete: 27.4%; Average loss: 3.2747\n",
      "Iteration: 1097; Percent complete: 27.4%; Average loss: 3.1615\n",
      "Iteration: 1098; Percent complete: 27.5%; Average loss: 3.4055\n",
      "Iteration: 1099; Percent complete: 27.5%; Average loss: 3.3436\n",
      "Iteration: 1100; Percent complete: 27.5%; Average loss: 3.5832\n",
      "Iteration: 1101; Percent complete: 27.5%; Average loss: 3.2311\n",
      "Iteration: 1102; Percent complete: 27.6%; Average loss: 3.2300\n",
      "Iteration: 1103; Percent complete: 27.6%; Average loss: 3.1982\n",
      "Iteration: 1104; Percent complete: 27.6%; Average loss: 3.6091\n",
      "Iteration: 1105; Percent complete: 27.6%; Average loss: 3.3604\n",
      "Iteration: 1106; Percent complete: 27.7%; Average loss: 3.3188\n",
      "Iteration: 1107; Percent complete: 27.7%; Average loss: 3.6750\n",
      "Iteration: 1108; Percent complete: 27.7%; Average loss: 3.2676\n",
      "Iteration: 1109; Percent complete: 27.7%; Average loss: 3.2908\n",
      "Iteration: 1110; Percent complete: 27.8%; Average loss: 3.3959\n",
      "Iteration: 1111; Percent complete: 27.8%; Average loss: 3.4379\n",
      "Iteration: 1112; Percent complete: 27.8%; Average loss: 3.5141\n",
      "Iteration: 1113; Percent complete: 27.8%; Average loss: 3.4156\n",
      "Iteration: 1114; Percent complete: 27.9%; Average loss: 3.3843\n",
      "Iteration: 1115; Percent complete: 27.9%; Average loss: 3.6410\n",
      "Iteration: 1116; Percent complete: 27.9%; Average loss: 3.4280\n",
      "Iteration: 1117; Percent complete: 27.9%; Average loss: 3.3228\n",
      "Iteration: 1118; Percent complete: 28.0%; Average loss: 3.3777\n",
      "Iteration: 1119; Percent complete: 28.0%; Average loss: 3.5392\n",
      "Iteration: 1120; Percent complete: 28.0%; Average loss: 3.4574\n",
      "Iteration: 1121; Percent complete: 28.0%; Average loss: 3.4040\n",
      "Iteration: 1122; Percent complete: 28.1%; Average loss: 3.6739\n",
      "Iteration: 1123; Percent complete: 28.1%; Average loss: 3.4699\n",
      "Iteration: 1124; Percent complete: 28.1%; Average loss: 3.6360\n",
      "Iteration: 1125; Percent complete: 28.1%; Average loss: 3.4984\n",
      "Iteration: 1126; Percent complete: 28.1%; Average loss: 3.1729\n",
      "Iteration: 1127; Percent complete: 28.2%; Average loss: 3.3701\n",
      "Iteration: 1128; Percent complete: 28.2%; Average loss: 3.3595\n",
      "Iteration: 1129; Percent complete: 28.2%; Average loss: 3.2268\n",
      "Iteration: 1130; Percent complete: 28.2%; Average loss: 3.4678\n",
      "Iteration: 1131; Percent complete: 28.3%; Average loss: 3.2218\n",
      "Iteration: 1132; Percent complete: 28.3%; Average loss: 3.4600\n",
      "Iteration: 1133; Percent complete: 28.3%; Average loss: 3.7927\n",
      "Iteration: 1134; Percent complete: 28.3%; Average loss: 3.8615\n",
      "Iteration: 1135; Percent complete: 28.4%; Average loss: 3.4705\n",
      "Iteration: 1136; Percent complete: 28.4%; Average loss: 3.3547\n",
      "Iteration: 1137; Percent complete: 28.4%; Average loss: 3.5572\n",
      "Iteration: 1138; Percent complete: 28.4%; Average loss: 3.4867\n",
      "Iteration: 1139; Percent complete: 28.5%; Average loss: 3.5853\n",
      "Iteration: 1140; Percent complete: 28.5%; Average loss: 3.4791\n",
      "Iteration: 1141; Percent complete: 28.5%; Average loss: 3.2583\n",
      "Iteration: 1142; Percent complete: 28.5%; Average loss: 3.3664\n",
      "Iteration: 1143; Percent complete: 28.6%; Average loss: 3.5229\n",
      "Iteration: 1144; Percent complete: 28.6%; Average loss: 3.3237\n",
      "Iteration: 1145; Percent complete: 28.6%; Average loss: 3.4619\n",
      "Iteration: 1146; Percent complete: 28.6%; Average loss: 3.3403\n",
      "Iteration: 1147; Percent complete: 28.7%; Average loss: 3.3371\n",
      "Iteration: 1148; Percent complete: 28.7%; Average loss: 3.2207\n",
      "Iteration: 1149; Percent complete: 28.7%; Average loss: 3.3400\n",
      "Iteration: 1150; Percent complete: 28.7%; Average loss: 3.4148\n",
      "Iteration: 1151; Percent complete: 28.8%; Average loss: 3.1426\n",
      "Iteration: 1152; Percent complete: 28.8%; Average loss: 3.5339\n",
      "Iteration: 1153; Percent complete: 28.8%; Average loss: 3.1954\n",
      "Iteration: 1154; Percent complete: 28.8%; Average loss: 3.4620\n",
      "Iteration: 1155; Percent complete: 28.9%; Average loss: 3.4512\n",
      "Iteration: 1156; Percent complete: 28.9%; Average loss: 3.5782\n",
      "Iteration: 1157; Percent complete: 28.9%; Average loss: 3.2359\n",
      "Iteration: 1158; Percent complete: 28.9%; Average loss: 3.4066\n",
      "Iteration: 1159; Percent complete: 29.0%; Average loss: 3.4000\n",
      "Iteration: 1160; Percent complete: 29.0%; Average loss: 3.3072\n",
      "Iteration: 1161; Percent complete: 29.0%; Average loss: 3.4318\n",
      "Iteration: 1162; Percent complete: 29.0%; Average loss: 3.6590\n",
      "Iteration: 1163; Percent complete: 29.1%; Average loss: 3.3421\n",
      "Iteration: 1164; Percent complete: 29.1%; Average loss: 3.5203\n",
      "Iteration: 1165; Percent complete: 29.1%; Average loss: 3.3265\n",
      "Iteration: 1166; Percent complete: 29.1%; Average loss: 3.3605\n",
      "Iteration: 1167; Percent complete: 29.2%; Average loss: 3.3047\n",
      "Iteration: 1168; Percent complete: 29.2%; Average loss: 3.4494\n",
      "Iteration: 1169; Percent complete: 29.2%; Average loss: 3.4205\n",
      "Iteration: 1170; Percent complete: 29.2%; Average loss: 3.5375\n",
      "Iteration: 1171; Percent complete: 29.3%; Average loss: 3.4284\n",
      "Iteration: 1172; Percent complete: 29.3%; Average loss: 3.3696\n",
      "Iteration: 1173; Percent complete: 29.3%; Average loss: 3.5658\n",
      "Iteration: 1174; Percent complete: 29.3%; Average loss: 3.3129\n",
      "Iteration: 1175; Percent complete: 29.4%; Average loss: 3.5378\n",
      "Iteration: 1176; Percent complete: 29.4%; Average loss: 3.4220\n",
      "Iteration: 1177; Percent complete: 29.4%; Average loss: 3.2198\n",
      "Iteration: 1178; Percent complete: 29.4%; Average loss: 3.3982\n",
      "Iteration: 1179; Percent complete: 29.5%; Average loss: 3.4349\n",
      "Iteration: 1180; Percent complete: 29.5%; Average loss: 3.2011\n",
      "Iteration: 1181; Percent complete: 29.5%; Average loss: 3.4070\n",
      "Iteration: 1182; Percent complete: 29.5%; Average loss: 3.3259\n",
      "Iteration: 1183; Percent complete: 29.6%; Average loss: 3.2612\n",
      "Iteration: 1184; Percent complete: 29.6%; Average loss: 3.4189\n",
      "Iteration: 1185; Percent complete: 29.6%; Average loss: 3.3999\n",
      "Iteration: 1186; Percent complete: 29.6%; Average loss: 3.4727\n",
      "Iteration: 1187; Percent complete: 29.7%; Average loss: 3.2705\n",
      "Iteration: 1188; Percent complete: 29.7%; Average loss: 3.4767\n",
      "Iteration: 1189; Percent complete: 29.7%; Average loss: 3.5149\n",
      "Iteration: 1190; Percent complete: 29.8%; Average loss: 3.2291\n",
      "Iteration: 1191; Percent complete: 29.8%; Average loss: 3.2837\n",
      "Iteration: 1192; Percent complete: 29.8%; Average loss: 3.5919\n",
      "Iteration: 1193; Percent complete: 29.8%; Average loss: 3.5753\n",
      "Iteration: 1194; Percent complete: 29.8%; Average loss: 3.4092\n",
      "Iteration: 1195; Percent complete: 29.9%; Average loss: 3.3503\n",
      "Iteration: 1196; Percent complete: 29.9%; Average loss: 3.2551\n",
      "Iteration: 1197; Percent complete: 29.9%; Average loss: 3.4091\n",
      "Iteration: 1198; Percent complete: 29.9%; Average loss: 3.3503\n",
      "Iteration: 1199; Percent complete: 30.0%; Average loss: 3.4942\n",
      "Iteration: 1200; Percent complete: 30.0%; Average loss: 3.3646\n",
      "Iteration: 1201; Percent complete: 30.0%; Average loss: 3.4337\n",
      "Iteration: 1202; Percent complete: 30.0%; Average loss: 3.3593\n",
      "Iteration: 1203; Percent complete: 30.1%; Average loss: 3.4334\n",
      "Iteration: 1204; Percent complete: 30.1%; Average loss: 3.2394\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 1205; Percent complete: 30.1%; Average loss: 3.4867\n",
      "Iteration: 1206; Percent complete: 30.1%; Average loss: 3.5143\n",
      "Iteration: 1207; Percent complete: 30.2%; Average loss: 3.3426\n",
      "Iteration: 1208; Percent complete: 30.2%; Average loss: 3.5327\n",
      "Iteration: 1209; Percent complete: 30.2%; Average loss: 3.2836\n",
      "Iteration: 1210; Percent complete: 30.2%; Average loss: 3.2905\n",
      "Iteration: 1211; Percent complete: 30.3%; Average loss: 3.3015\n",
      "Iteration: 1212; Percent complete: 30.3%; Average loss: 3.2108\n",
      "Iteration: 1213; Percent complete: 30.3%; Average loss: 3.5277\n",
      "Iteration: 1214; Percent complete: 30.3%; Average loss: 3.6559\n",
      "Iteration: 1215; Percent complete: 30.4%; Average loss: 3.3732\n",
      "Iteration: 1216; Percent complete: 30.4%; Average loss: 3.5041\n",
      "Iteration: 1217; Percent complete: 30.4%; Average loss: 3.4471\n",
      "Iteration: 1218; Percent complete: 30.4%; Average loss: 3.6975\n",
      "Iteration: 1219; Percent complete: 30.5%; Average loss: 3.4697\n",
      "Iteration: 1220; Percent complete: 30.5%; Average loss: 3.3774\n",
      "Iteration: 1221; Percent complete: 30.5%; Average loss: 3.3234\n",
      "Iteration: 1222; Percent complete: 30.6%; Average loss: 3.3570\n",
      "Iteration: 1223; Percent complete: 30.6%; Average loss: 3.4198\n",
      "Iteration: 1224; Percent complete: 30.6%; Average loss: 3.2905\n",
      "Iteration: 1225; Percent complete: 30.6%; Average loss: 3.6003\n",
      "Iteration: 1226; Percent complete: 30.6%; Average loss: 3.3610\n",
      "Iteration: 1227; Percent complete: 30.7%; Average loss: 3.3405\n",
      "Iteration: 1228; Percent complete: 30.7%; Average loss: 3.3196\n",
      "Iteration: 1229; Percent complete: 30.7%; Average loss: 3.3394\n",
      "Iteration: 1230; Percent complete: 30.8%; Average loss: 2.9264\n",
      "Iteration: 1231; Percent complete: 30.8%; Average loss: 3.3648\n",
      "Iteration: 1232; Percent complete: 30.8%; Average loss: 3.2583\n",
      "Iteration: 1233; Percent complete: 30.8%; Average loss: 3.5706\n",
      "Iteration: 1234; Percent complete: 30.9%; Average loss: 3.3586\n",
      "Iteration: 1235; Percent complete: 30.9%; Average loss: 3.2439\n",
      "Iteration: 1236; Percent complete: 30.9%; Average loss: 3.0454\n",
      "Iteration: 1237; Percent complete: 30.9%; Average loss: 3.3657\n",
      "Iteration: 1238; Percent complete: 30.9%; Average loss: 3.4897\n",
      "Iteration: 1239; Percent complete: 31.0%; Average loss: 3.1199\n",
      "Iteration: 1240; Percent complete: 31.0%; Average loss: 3.2883\n",
      "Iteration: 1241; Percent complete: 31.0%; Average loss: 3.5460\n",
      "Iteration: 1242; Percent complete: 31.1%; Average loss: 3.4160\n",
      "Iteration: 1243; Percent complete: 31.1%; Average loss: 3.2835\n",
      "Iteration: 1244; Percent complete: 31.1%; Average loss: 3.5006\n",
      "Iteration: 1245; Percent complete: 31.1%; Average loss: 3.2725\n",
      "Iteration: 1246; Percent complete: 31.1%; Average loss: 3.2236\n",
      "Iteration: 1247; Percent complete: 31.2%; Average loss: 3.6859\n",
      "Iteration: 1248; Percent complete: 31.2%; Average loss: 3.2220\n",
      "Iteration: 1249; Percent complete: 31.2%; Average loss: 3.1745\n",
      "Iteration: 1250; Percent complete: 31.2%; Average loss: 3.1968\n",
      "Iteration: 1251; Percent complete: 31.3%; Average loss: 3.3746\n",
      "Iteration: 1252; Percent complete: 31.3%; Average loss: 3.1647\n",
      "Iteration: 1253; Percent complete: 31.3%; Average loss: 3.5327\n",
      "Iteration: 1254; Percent complete: 31.4%; Average loss: 3.4568\n",
      "Iteration: 1255; Percent complete: 31.4%; Average loss: 3.2903\n",
      "Iteration: 1256; Percent complete: 31.4%; Average loss: 3.4703\n",
      "Iteration: 1257; Percent complete: 31.4%; Average loss: 3.4256\n",
      "Iteration: 1258; Percent complete: 31.4%; Average loss: 3.3231\n",
      "Iteration: 1259; Percent complete: 31.5%; Average loss: 3.6002\n",
      "Iteration: 1260; Percent complete: 31.5%; Average loss: 3.3524\n",
      "Iteration: 1261; Percent complete: 31.5%; Average loss: 3.4068\n",
      "Iteration: 1262; Percent complete: 31.6%; Average loss: 3.3473\n",
      "Iteration: 1263; Percent complete: 31.6%; Average loss: 3.6330\n",
      "Iteration: 1264; Percent complete: 31.6%; Average loss: 3.4630\n",
      "Iteration: 1265; Percent complete: 31.6%; Average loss: 3.5681\n",
      "Iteration: 1266; Percent complete: 31.6%; Average loss: 3.4538\n",
      "Iteration: 1267; Percent complete: 31.7%; Average loss: 3.4058\n",
      "Iteration: 1268; Percent complete: 31.7%; Average loss: 3.1465\n",
      "Iteration: 1269; Percent complete: 31.7%; Average loss: 3.2137\n",
      "Iteration: 1270; Percent complete: 31.8%; Average loss: 3.4793\n",
      "Iteration: 1271; Percent complete: 31.8%; Average loss: 3.2321\n",
      "Iteration: 1272; Percent complete: 31.8%; Average loss: 3.2148\n",
      "Iteration: 1273; Percent complete: 31.8%; Average loss: 3.4382\n",
      "Iteration: 1274; Percent complete: 31.9%; Average loss: 3.2840\n",
      "Iteration: 1275; Percent complete: 31.9%; Average loss: 3.1977\n",
      "Iteration: 1276; Percent complete: 31.9%; Average loss: 3.5999\n",
      "Iteration: 1277; Percent complete: 31.9%; Average loss: 3.2189\n",
      "Iteration: 1278; Percent complete: 31.9%; Average loss: 3.3458\n",
      "Iteration: 1279; Percent complete: 32.0%; Average loss: 3.3196\n",
      "Iteration: 1280; Percent complete: 32.0%; Average loss: 3.4586\n",
      "Iteration: 1281; Percent complete: 32.0%; Average loss: 3.1887\n",
      "Iteration: 1282; Percent complete: 32.0%; Average loss: 3.4725\n",
      "Iteration: 1283; Percent complete: 32.1%; Average loss: 3.6787\n",
      "Iteration: 1284; Percent complete: 32.1%; Average loss: 3.2661\n",
      "Iteration: 1285; Percent complete: 32.1%; Average loss: 3.3279\n",
      "Iteration: 1286; Percent complete: 32.1%; Average loss: 3.3716\n",
      "Iteration: 1287; Percent complete: 32.2%; Average loss: 3.5541\n",
      "Iteration: 1288; Percent complete: 32.2%; Average loss: 3.2984\n",
      "Iteration: 1289; Percent complete: 32.2%; Average loss: 3.1005\n",
      "Iteration: 1290; Percent complete: 32.2%; Average loss: 3.2455\n",
      "Iteration: 1291; Percent complete: 32.3%; Average loss: 3.4113\n",
      "Iteration: 1292; Percent complete: 32.3%; Average loss: 3.3758\n",
      "Iteration: 1293; Percent complete: 32.3%; Average loss: 3.1330\n",
      "Iteration: 1294; Percent complete: 32.4%; Average loss: 3.4126\n",
      "Iteration: 1295; Percent complete: 32.4%; Average loss: 3.4048\n",
      "Iteration: 1296; Percent complete: 32.4%; Average loss: 3.3417\n",
      "Iteration: 1297; Percent complete: 32.4%; Average loss: 3.3758\n",
      "Iteration: 1298; Percent complete: 32.5%; Average loss: 3.3359\n",
      "Iteration: 1299; Percent complete: 32.5%; Average loss: 3.4714\n",
      "Iteration: 1300; Percent complete: 32.5%; Average loss: 3.4015\n",
      "Iteration: 1301; Percent complete: 32.5%; Average loss: 3.2484\n",
      "Iteration: 1302; Percent complete: 32.6%; Average loss: 3.2769\n",
      "Iteration: 1303; Percent complete: 32.6%; Average loss: 3.4929\n",
      "Iteration: 1304; Percent complete: 32.6%; Average loss: 3.3140\n",
      "Iteration: 1305; Percent complete: 32.6%; Average loss: 3.2778\n",
      "Iteration: 1306; Percent complete: 32.6%; Average loss: 3.4040\n",
      "Iteration: 1307; Percent complete: 32.7%; Average loss: 3.2317\n",
      "Iteration: 1308; Percent complete: 32.7%; Average loss: 3.1034\n",
      "Iteration: 1309; Percent complete: 32.7%; Average loss: 3.4579\n",
      "Iteration: 1310; Percent complete: 32.8%; Average loss: 3.2490\n",
      "Iteration: 1311; Percent complete: 32.8%; Average loss: 3.1410\n",
      "Iteration: 1312; Percent complete: 32.8%; Average loss: 3.1884\n",
      "Iteration: 1313; Percent complete: 32.8%; Average loss: 3.3557\n",
      "Iteration: 1314; Percent complete: 32.9%; Average loss: 3.4062\n",
      "Iteration: 1315; Percent complete: 32.9%; Average loss: 3.1519\n",
      "Iteration: 1316; Percent complete: 32.9%; Average loss: 3.3593\n",
      "Iteration: 1317; Percent complete: 32.9%; Average loss: 3.2053\n",
      "Iteration: 1318; Percent complete: 33.0%; Average loss: 3.1484\n",
      "Iteration: 1319; Percent complete: 33.0%; Average loss: 3.2640\n",
      "Iteration: 1320; Percent complete: 33.0%; Average loss: 3.3152\n",
      "Iteration: 1321; Percent complete: 33.0%; Average loss: 3.3977\n",
      "Iteration: 1322; Percent complete: 33.1%; Average loss: 3.4577\n",
      "Iteration: 1323; Percent complete: 33.1%; Average loss: 3.3831\n",
      "Iteration: 1324; Percent complete: 33.1%; Average loss: 3.1935\n",
      "Iteration: 1325; Percent complete: 33.1%; Average loss: 3.2958\n",
      "Iteration: 1326; Percent complete: 33.1%; Average loss: 3.3256\n",
      "Iteration: 1327; Percent complete: 33.2%; Average loss: 3.7084\n",
      "Iteration: 1328; Percent complete: 33.2%; Average loss: 3.3956\n",
      "Iteration: 1329; Percent complete: 33.2%; Average loss: 3.3487\n",
      "Iteration: 1330; Percent complete: 33.2%; Average loss: 3.4415\n",
      "Iteration: 1331; Percent complete: 33.3%; Average loss: 3.5579\n",
      "Iteration: 1332; Percent complete: 33.3%; Average loss: 3.3049\n",
      "Iteration: 1333; Percent complete: 33.3%; Average loss: 3.5370\n",
      "Iteration: 1334; Percent complete: 33.4%; Average loss: 3.4105\n",
      "Iteration: 1335; Percent complete: 33.4%; Average loss: 3.5020\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 1336; Percent complete: 33.4%; Average loss: 3.3207\n",
      "Iteration: 1337; Percent complete: 33.4%; Average loss: 3.1582\n",
      "Iteration: 1338; Percent complete: 33.5%; Average loss: 3.3461\n",
      "Iteration: 1339; Percent complete: 33.5%; Average loss: 3.2828\n",
      "Iteration: 1340; Percent complete: 33.5%; Average loss: 3.1159\n",
      "Iteration: 1341; Percent complete: 33.5%; Average loss: 3.2086\n",
      "Iteration: 1342; Percent complete: 33.6%; Average loss: 3.5746\n",
      "Iteration: 1343; Percent complete: 33.6%; Average loss: 3.2775\n",
      "Iteration: 1344; Percent complete: 33.6%; Average loss: 3.5805\n",
      "Iteration: 1345; Percent complete: 33.6%; Average loss: 3.3048\n",
      "Iteration: 1346; Percent complete: 33.7%; Average loss: 3.2479\n",
      "Iteration: 1347; Percent complete: 33.7%; Average loss: 3.2630\n",
      "Iteration: 1348; Percent complete: 33.7%; Average loss: 3.2053\n",
      "Iteration: 1349; Percent complete: 33.7%; Average loss: 3.2782\n",
      "Iteration: 1350; Percent complete: 33.8%; Average loss: 3.3101\n",
      "Iteration: 1351; Percent complete: 33.8%; Average loss: 3.2408\n",
      "Iteration: 1352; Percent complete: 33.8%; Average loss: 3.4710\n",
      "Iteration: 1353; Percent complete: 33.8%; Average loss: 3.4114\n",
      "Iteration: 1354; Percent complete: 33.9%; Average loss: 3.4966\n",
      "Iteration: 1355; Percent complete: 33.9%; Average loss: 3.2622\n",
      "Iteration: 1356; Percent complete: 33.9%; Average loss: 3.3756\n",
      "Iteration: 1357; Percent complete: 33.9%; Average loss: 3.0096\n",
      "Iteration: 1358; Percent complete: 34.0%; Average loss: 3.3654\n",
      "Iteration: 1359; Percent complete: 34.0%; Average loss: 3.2822\n",
      "Iteration: 1360; Percent complete: 34.0%; Average loss: 3.1590\n",
      "Iteration: 1361; Percent complete: 34.0%; Average loss: 3.4554\n",
      "Iteration: 1362; Percent complete: 34.1%; Average loss: 3.4148\n",
      "Iteration: 1363; Percent complete: 34.1%; Average loss: 3.3187\n",
      "Iteration: 1364; Percent complete: 34.1%; Average loss: 3.1677\n",
      "Iteration: 1365; Percent complete: 34.1%; Average loss: 3.2663\n",
      "Iteration: 1366; Percent complete: 34.2%; Average loss: 3.0893\n",
      "Iteration: 1367; Percent complete: 34.2%; Average loss: 3.0964\n",
      "Iteration: 1368; Percent complete: 34.2%; Average loss: 3.3757\n",
      "Iteration: 1369; Percent complete: 34.2%; Average loss: 3.2482\n",
      "Iteration: 1370; Percent complete: 34.2%; Average loss: 3.0580\n",
      "Iteration: 1371; Percent complete: 34.3%; Average loss: 3.0940\n",
      "Iteration: 1372; Percent complete: 34.3%; Average loss: 3.1447\n",
      "Iteration: 1373; Percent complete: 34.3%; Average loss: 3.3075\n",
      "Iteration: 1374; Percent complete: 34.4%; Average loss: 3.3985\n",
      "Iteration: 1375; Percent complete: 34.4%; Average loss: 3.1220\n",
      "Iteration: 1376; Percent complete: 34.4%; Average loss: 3.2526\n",
      "Iteration: 1377; Percent complete: 34.4%; Average loss: 3.0757\n",
      "Iteration: 1378; Percent complete: 34.4%; Average loss: 3.2768\n",
      "Iteration: 1379; Percent complete: 34.5%; Average loss: 3.4456\n",
      "Iteration: 1380; Percent complete: 34.5%; Average loss: 3.3458\n",
      "Iteration: 1381; Percent complete: 34.5%; Average loss: 3.1764\n",
      "Iteration: 1382; Percent complete: 34.5%; Average loss: 3.6542\n",
      "Iteration: 1383; Percent complete: 34.6%; Average loss: 3.2273\n",
      "Iteration: 1384; Percent complete: 34.6%; Average loss: 3.3092\n",
      "Iteration: 1385; Percent complete: 34.6%; Average loss: 3.1894\n",
      "Iteration: 1386; Percent complete: 34.6%; Average loss: 3.3527\n",
      "Iteration: 1387; Percent complete: 34.7%; Average loss: 3.4597\n",
      "Iteration: 1388; Percent complete: 34.7%; Average loss: 3.3401\n",
      "Iteration: 1389; Percent complete: 34.7%; Average loss: 3.3427\n",
      "Iteration: 1390; Percent complete: 34.8%; Average loss: 3.3507\n",
      "Iteration: 1391; Percent complete: 34.8%; Average loss: 3.0494\n",
      "Iteration: 1392; Percent complete: 34.8%; Average loss: 3.1884\n",
      "Iteration: 1393; Percent complete: 34.8%; Average loss: 3.4821\n",
      "Iteration: 1394; Percent complete: 34.8%; Average loss: 3.5544\n",
      "Iteration: 1395; Percent complete: 34.9%; Average loss: 3.6064\n",
      "Iteration: 1396; Percent complete: 34.9%; Average loss: 3.4218\n",
      "Iteration: 1397; Percent complete: 34.9%; Average loss: 3.3256\n",
      "Iteration: 1398; Percent complete: 34.9%; Average loss: 3.3547\n",
      "Iteration: 1399; Percent complete: 35.0%; Average loss: 3.2337\n",
      "Iteration: 1400; Percent complete: 35.0%; Average loss: 3.2696\n",
      "Iteration: 1401; Percent complete: 35.0%; Average loss: 3.6629\n",
      "Iteration: 1402; Percent complete: 35.0%; Average loss: 3.4088\n",
      "Iteration: 1403; Percent complete: 35.1%; Average loss: 3.1340\n",
      "Iteration: 1404; Percent complete: 35.1%; Average loss: 3.2596\n",
      "Iteration: 1405; Percent complete: 35.1%; Average loss: 3.3130\n",
      "Iteration: 1406; Percent complete: 35.1%; Average loss: 3.2235\n",
      "Iteration: 1407; Percent complete: 35.2%; Average loss: 3.2398\n",
      "Iteration: 1408; Percent complete: 35.2%; Average loss: 3.2513\n",
      "Iteration: 1409; Percent complete: 35.2%; Average loss: 3.1432\n",
      "Iteration: 1410; Percent complete: 35.2%; Average loss: 3.5628\n",
      "Iteration: 1411; Percent complete: 35.3%; Average loss: 3.4285\n",
      "Iteration: 1412; Percent complete: 35.3%; Average loss: 3.5006\n",
      "Iteration: 1413; Percent complete: 35.3%; Average loss: 3.2414\n",
      "Iteration: 1414; Percent complete: 35.4%; Average loss: 3.5737\n",
      "Iteration: 1415; Percent complete: 35.4%; Average loss: 3.4328\n",
      "Iteration: 1416; Percent complete: 35.4%; Average loss: 3.3681\n",
      "Iteration: 1417; Percent complete: 35.4%; Average loss: 3.2249\n",
      "Iteration: 1418; Percent complete: 35.4%; Average loss: 3.1948\n",
      "Iteration: 1419; Percent complete: 35.5%; Average loss: 3.5697\n",
      "Iteration: 1420; Percent complete: 35.5%; Average loss: 3.2729\n",
      "Iteration: 1421; Percent complete: 35.5%; Average loss: 3.4546\n",
      "Iteration: 1422; Percent complete: 35.5%; Average loss: 2.7930\n",
      "Iteration: 1423; Percent complete: 35.6%; Average loss: 3.1335\n",
      "Iteration: 1424; Percent complete: 35.6%; Average loss: 3.5685\n",
      "Iteration: 1425; Percent complete: 35.6%; Average loss: 3.2996\n",
      "Iteration: 1426; Percent complete: 35.6%; Average loss: 3.4702\n",
      "Iteration: 1427; Percent complete: 35.7%; Average loss: 3.3207\n",
      "Iteration: 1428; Percent complete: 35.7%; Average loss: 3.3723\n",
      "Iteration: 1429; Percent complete: 35.7%; Average loss: 3.2335\n",
      "Iteration: 1430; Percent complete: 35.8%; Average loss: 3.3598\n",
      "Iteration: 1431; Percent complete: 35.8%; Average loss: 3.5069\n",
      "Iteration: 1432; Percent complete: 35.8%; Average loss: 3.1070\n",
      "Iteration: 1433; Percent complete: 35.8%; Average loss: 3.4091\n",
      "Iteration: 1434; Percent complete: 35.9%; Average loss: 3.4798\n",
      "Iteration: 1435; Percent complete: 35.9%; Average loss: 3.3870\n",
      "Iteration: 1436; Percent complete: 35.9%; Average loss: 3.4720\n",
      "Iteration: 1437; Percent complete: 35.9%; Average loss: 2.9939\n",
      "Iteration: 1438; Percent complete: 35.9%; Average loss: 3.2686\n",
      "Iteration: 1439; Percent complete: 36.0%; Average loss: 3.0927\n",
      "Iteration: 1440; Percent complete: 36.0%; Average loss: 3.3464\n",
      "Iteration: 1441; Percent complete: 36.0%; Average loss: 3.4481\n",
      "Iteration: 1442; Percent complete: 36.0%; Average loss: 3.3077\n",
      "Iteration: 1443; Percent complete: 36.1%; Average loss: 3.1879\n",
      "Iteration: 1444; Percent complete: 36.1%; Average loss: 3.4017\n",
      "Iteration: 1445; Percent complete: 36.1%; Average loss: 3.1433\n",
      "Iteration: 1446; Percent complete: 36.1%; Average loss: 3.2576\n",
      "Iteration: 1447; Percent complete: 36.2%; Average loss: 3.3897\n",
      "Iteration: 1448; Percent complete: 36.2%; Average loss: 3.4596\n",
      "Iteration: 1449; Percent complete: 36.2%; Average loss: 3.2619\n",
      "Iteration: 1450; Percent complete: 36.2%; Average loss: 3.2908\n",
      "Iteration: 1451; Percent complete: 36.3%; Average loss: 3.2871\n",
      "Iteration: 1452; Percent complete: 36.3%; Average loss: 3.2987\n",
      "Iteration: 1453; Percent complete: 36.3%; Average loss: 3.5870\n",
      "Iteration: 1454; Percent complete: 36.4%; Average loss: 3.3103\n",
      "Iteration: 1455; Percent complete: 36.4%; Average loss: 3.2629\n",
      "Iteration: 1456; Percent complete: 36.4%; Average loss: 3.2315\n",
      "Iteration: 1457; Percent complete: 36.4%; Average loss: 3.3359\n",
      "Iteration: 1458; Percent complete: 36.4%; Average loss: 3.3497\n",
      "Iteration: 1459; Percent complete: 36.5%; Average loss: 3.0903\n",
      "Iteration: 1460; Percent complete: 36.5%; Average loss: 3.2908\n",
      "Iteration: 1461; Percent complete: 36.5%; Average loss: 3.3704\n",
      "Iteration: 1462; Percent complete: 36.5%; Average loss: 3.4013\n",
      "Iteration: 1463; Percent complete: 36.6%; Average loss: 3.0727\n",
      "Iteration: 1464; Percent complete: 36.6%; Average loss: 3.6414\n",
      "Iteration: 1465; Percent complete: 36.6%; Average loss: 3.3884\n",
      "Iteration: 1466; Percent complete: 36.6%; Average loss: 3.5176\n",
      "Iteration: 1467; Percent complete: 36.7%; Average loss: 3.6143\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 1468; Percent complete: 36.7%; Average loss: 3.1557\n",
      "Iteration: 1469; Percent complete: 36.7%; Average loss: 3.4816\n",
      "Iteration: 1470; Percent complete: 36.8%; Average loss: 3.2615\n",
      "Iteration: 1471; Percent complete: 36.8%; Average loss: 3.4536\n",
      "Iteration: 1472; Percent complete: 36.8%; Average loss: 2.9738\n",
      "Iteration: 1473; Percent complete: 36.8%; Average loss: 3.0094\n",
      "Iteration: 1474; Percent complete: 36.9%; Average loss: 3.1762\n",
      "Iteration: 1475; Percent complete: 36.9%; Average loss: 3.1916\n",
      "Iteration: 1476; Percent complete: 36.9%; Average loss: 3.3216\n",
      "Iteration: 1477; Percent complete: 36.9%; Average loss: 3.2310\n",
      "Iteration: 1478; Percent complete: 37.0%; Average loss: 3.1913\n",
      "Iteration: 1479; Percent complete: 37.0%; Average loss: 3.3487\n",
      "Iteration: 1480; Percent complete: 37.0%; Average loss: 3.3085\n",
      "Iteration: 1481; Percent complete: 37.0%; Average loss: 3.3070\n",
      "Iteration: 1482; Percent complete: 37.0%; Average loss: 3.3703\n",
      "Iteration: 1483; Percent complete: 37.1%; Average loss: 3.1817\n",
      "Iteration: 1484; Percent complete: 37.1%; Average loss: 3.3309\n",
      "Iteration: 1485; Percent complete: 37.1%; Average loss: 3.5066\n",
      "Iteration: 1486; Percent complete: 37.1%; Average loss: 3.3314\n",
      "Iteration: 1487; Percent complete: 37.2%; Average loss: 3.3729\n",
      "Iteration: 1488; Percent complete: 37.2%; Average loss: 3.2953\n",
      "Iteration: 1489; Percent complete: 37.2%; Average loss: 3.1715\n",
      "Iteration: 1490; Percent complete: 37.2%; Average loss: 3.3634\n",
      "Iteration: 1491; Percent complete: 37.3%; Average loss: 3.4669\n",
      "Iteration: 1492; Percent complete: 37.3%; Average loss: 3.2970\n",
      "Iteration: 1493; Percent complete: 37.3%; Average loss: 3.0905\n",
      "Iteration: 1494; Percent complete: 37.4%; Average loss: 3.0968\n",
      "Iteration: 1495; Percent complete: 37.4%; Average loss: 3.3884\n",
      "Iteration: 1496; Percent complete: 37.4%; Average loss: 3.0604\n",
      "Iteration: 1497; Percent complete: 37.4%; Average loss: 3.3188\n",
      "Iteration: 1498; Percent complete: 37.5%; Average loss: 3.2071\n",
      "Iteration: 1499; Percent complete: 37.5%; Average loss: 3.3353\n",
      "Iteration: 1500; Percent complete: 37.5%; Average loss: 3.4427\n",
      "Iteration: 1501; Percent complete: 37.5%; Average loss: 3.2437\n",
      "Iteration: 1502; Percent complete: 37.5%; Average loss: 3.3504\n",
      "Iteration: 1503; Percent complete: 37.6%; Average loss: 3.3375\n",
      "Iteration: 1504; Percent complete: 37.6%; Average loss: 3.3813\n",
      "Iteration: 1505; Percent complete: 37.6%; Average loss: 3.3619\n",
      "Iteration: 1506; Percent complete: 37.6%; Average loss: 3.3547\n",
      "Iteration: 1507; Percent complete: 37.7%; Average loss: 3.4065\n",
      "Iteration: 1508; Percent complete: 37.7%; Average loss: 3.3838\n",
      "Iteration: 1509; Percent complete: 37.7%; Average loss: 3.1373\n",
      "Iteration: 1510; Percent complete: 37.8%; Average loss: 3.1284\n",
      "Iteration: 1511; Percent complete: 37.8%; Average loss: 3.3770\n",
      "Iteration: 1512; Percent complete: 37.8%; Average loss: 3.4898\n",
      "Iteration: 1513; Percent complete: 37.8%; Average loss: 3.0582\n",
      "Iteration: 1514; Percent complete: 37.9%; Average loss: 3.4596\n",
      "Iteration: 1515; Percent complete: 37.9%; Average loss: 3.2181\n",
      "Iteration: 1516; Percent complete: 37.9%; Average loss: 3.1854\n",
      "Iteration: 1517; Percent complete: 37.9%; Average loss: 3.2488\n",
      "Iteration: 1518; Percent complete: 38.0%; Average loss: 3.3061\n",
      "Iteration: 1519; Percent complete: 38.0%; Average loss: 3.1166\n",
      "Iteration: 1520; Percent complete: 38.0%; Average loss: 3.5177\n",
      "Iteration: 1521; Percent complete: 38.0%; Average loss: 3.2768\n",
      "Iteration: 1522; Percent complete: 38.0%; Average loss: 3.4038\n",
      "Iteration: 1523; Percent complete: 38.1%; Average loss: 3.3451\n",
      "Iteration: 1524; Percent complete: 38.1%; Average loss: 3.0731\n",
      "Iteration: 1525; Percent complete: 38.1%; Average loss: 3.1037\n",
      "Iteration: 1526; Percent complete: 38.1%; Average loss: 3.2633\n",
      "Iteration: 1527; Percent complete: 38.2%; Average loss: 3.2848\n",
      "Iteration: 1528; Percent complete: 38.2%; Average loss: 3.2618\n",
      "Iteration: 1529; Percent complete: 38.2%; Average loss: 3.4976\n",
      "Iteration: 1530; Percent complete: 38.2%; Average loss: 3.1693\n",
      "Iteration: 1531; Percent complete: 38.3%; Average loss: 3.2471\n",
      "Iteration: 1532; Percent complete: 38.3%; Average loss: 3.5298\n",
      "Iteration: 1533; Percent complete: 38.3%; Average loss: 3.0585\n",
      "Iteration: 1534; Percent complete: 38.4%; Average loss: 3.2257\n",
      "Iteration: 1535; Percent complete: 38.4%; Average loss: 3.3659\n",
      "Iteration: 1536; Percent complete: 38.4%; Average loss: 3.0774\n",
      "Iteration: 1537; Percent complete: 38.4%; Average loss: 3.5246\n",
      "Iteration: 1538; Percent complete: 38.5%; Average loss: 3.2436\n",
      "Iteration: 1539; Percent complete: 38.5%; Average loss: 3.3938\n",
      "Iteration: 1540; Percent complete: 38.5%; Average loss: 3.2386\n",
      "Iteration: 1541; Percent complete: 38.5%; Average loss: 3.4183\n",
      "Iteration: 1542; Percent complete: 38.6%; Average loss: 3.2383\n",
      "Iteration: 1543; Percent complete: 38.6%; Average loss: 3.3476\n",
      "Iteration: 1544; Percent complete: 38.6%; Average loss: 3.4335\n",
      "Iteration: 1545; Percent complete: 38.6%; Average loss: 3.0738\n",
      "Iteration: 1546; Percent complete: 38.6%; Average loss: 3.4456\n",
      "Iteration: 1547; Percent complete: 38.7%; Average loss: 3.3731\n",
      "Iteration: 1548; Percent complete: 38.7%; Average loss: 3.2081\n",
      "Iteration: 1549; Percent complete: 38.7%; Average loss: 3.1216\n",
      "Iteration: 1550; Percent complete: 38.8%; Average loss: 3.2895\n",
      "Iteration: 1551; Percent complete: 38.8%; Average loss: 3.1716\n",
      "Iteration: 1552; Percent complete: 38.8%; Average loss: 3.1424\n",
      "Iteration: 1553; Percent complete: 38.8%; Average loss: 3.3526\n",
      "Iteration: 1554; Percent complete: 38.9%; Average loss: 3.3605\n",
      "Iteration: 1555; Percent complete: 38.9%; Average loss: 3.5908\n",
      "Iteration: 1556; Percent complete: 38.9%; Average loss: 3.2344\n",
      "Iteration: 1557; Percent complete: 38.9%; Average loss: 3.1898\n",
      "Iteration: 1558; Percent complete: 39.0%; Average loss: 2.9491\n",
      "Iteration: 1559; Percent complete: 39.0%; Average loss: 3.1964\n",
      "Iteration: 1560; Percent complete: 39.0%; Average loss: 3.2455\n",
      "Iteration: 1561; Percent complete: 39.0%; Average loss: 3.1754\n",
      "Iteration: 1562; Percent complete: 39.1%; Average loss: 3.1735\n",
      "Iteration: 1563; Percent complete: 39.1%; Average loss: 3.7344\n",
      "Iteration: 1564; Percent complete: 39.1%; Average loss: 3.2131\n",
      "Iteration: 1565; Percent complete: 39.1%; Average loss: 3.3544\n",
      "Iteration: 1566; Percent complete: 39.1%; Average loss: 3.3213\n",
      "Iteration: 1567; Percent complete: 39.2%; Average loss: 3.0537\n",
      "Iteration: 1568; Percent complete: 39.2%; Average loss: 3.0979\n",
      "Iteration: 1569; Percent complete: 39.2%; Average loss: 3.4717\n",
      "Iteration: 1570; Percent complete: 39.2%; Average loss: 3.6194\n",
      "Iteration: 1571; Percent complete: 39.3%; Average loss: 3.2685\n",
      "Iteration: 1572; Percent complete: 39.3%; Average loss: 3.0659\n",
      "Iteration: 1573; Percent complete: 39.3%; Average loss: 3.0659\n",
      "Iteration: 1574; Percent complete: 39.4%; Average loss: 3.2674\n",
      "Iteration: 1575; Percent complete: 39.4%; Average loss: 3.2034\n",
      "Iteration: 1576; Percent complete: 39.4%; Average loss: 3.3158\n",
      "Iteration: 1577; Percent complete: 39.4%; Average loss: 3.3070\n",
      "Iteration: 1578; Percent complete: 39.5%; Average loss: 3.1460\n",
      "Iteration: 1579; Percent complete: 39.5%; Average loss: 3.0670\n",
      "Iteration: 1580; Percent complete: 39.5%; Average loss: 3.1581\n",
      "Iteration: 1581; Percent complete: 39.5%; Average loss: 3.1772\n",
      "Iteration: 1582; Percent complete: 39.6%; Average loss: 3.0440\n",
      "Iteration: 1583; Percent complete: 39.6%; Average loss: 3.2499\n",
      "Iteration: 1584; Percent complete: 39.6%; Average loss: 3.3587\n",
      "Iteration: 1585; Percent complete: 39.6%; Average loss: 3.1388\n",
      "Iteration: 1586; Percent complete: 39.6%; Average loss: 3.3138\n",
      "Iteration: 1587; Percent complete: 39.7%; Average loss: 3.1593\n",
      "Iteration: 1588; Percent complete: 39.7%; Average loss: 3.2224\n",
      "Iteration: 1589; Percent complete: 39.7%; Average loss: 3.2855\n",
      "Iteration: 1590; Percent complete: 39.8%; Average loss: 3.3112\n",
      "Iteration: 1591; Percent complete: 39.8%; Average loss: 3.2701\n",
      "Iteration: 1592; Percent complete: 39.8%; Average loss: 3.4321\n",
      "Iteration: 1593; Percent complete: 39.8%; Average loss: 3.4694\n",
      "Iteration: 1594; Percent complete: 39.9%; Average loss: 3.1314\n",
      "Iteration: 1595; Percent complete: 39.9%; Average loss: 3.2873\n",
      "Iteration: 1596; Percent complete: 39.9%; Average loss: 3.3827\n",
      "Iteration: 1597; Percent complete: 39.9%; Average loss: 3.2370\n",
      "Iteration: 1598; Percent complete: 40.0%; Average loss: 3.3248\n",
      "Iteration: 1599; Percent complete: 40.0%; Average loss: 3.2073\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 1600; Percent complete: 40.0%; Average loss: 3.2233\n",
      "Iteration: 1601; Percent complete: 40.0%; Average loss: 3.3306\n",
      "Iteration: 1602; Percent complete: 40.1%; Average loss: 3.3002\n",
      "Iteration: 1603; Percent complete: 40.1%; Average loss: 3.2689\n",
      "Iteration: 1604; Percent complete: 40.1%; Average loss: 3.3448\n",
      "Iteration: 1605; Percent complete: 40.1%; Average loss: 3.2265\n",
      "Iteration: 1606; Percent complete: 40.2%; Average loss: 3.5111\n",
      "Iteration: 1607; Percent complete: 40.2%; Average loss: 3.1944\n",
      "Iteration: 1608; Percent complete: 40.2%; Average loss: 3.3515\n",
      "Iteration: 1609; Percent complete: 40.2%; Average loss: 3.1824\n",
      "Iteration: 1610; Percent complete: 40.2%; Average loss: 3.2950\n",
      "Iteration: 1611; Percent complete: 40.3%; Average loss: 3.1559\n",
      "Iteration: 1612; Percent complete: 40.3%; Average loss: 3.1547\n",
      "Iteration: 1613; Percent complete: 40.3%; Average loss: 2.9107\n",
      "Iteration: 1614; Percent complete: 40.4%; Average loss: 3.3274\n",
      "Iteration: 1615; Percent complete: 40.4%; Average loss: 3.1943\n",
      "Iteration: 1616; Percent complete: 40.4%; Average loss: 3.2953\n",
      "Iteration: 1617; Percent complete: 40.4%; Average loss: 3.2308\n",
      "Iteration: 1618; Percent complete: 40.5%; Average loss: 3.1663\n",
      "Iteration: 1619; Percent complete: 40.5%; Average loss: 3.3910\n",
      "Iteration: 1620; Percent complete: 40.5%; Average loss: 3.3174\n",
      "Iteration: 1621; Percent complete: 40.5%; Average loss: 3.1929\n",
      "Iteration: 1622; Percent complete: 40.6%; Average loss: 3.3048\n",
      "Iteration: 1623; Percent complete: 40.6%; Average loss: 3.2297\n",
      "Iteration: 1624; Percent complete: 40.6%; Average loss: 3.2654\n",
      "Iteration: 1625; Percent complete: 40.6%; Average loss: 3.1631\n",
      "Iteration: 1626; Percent complete: 40.6%; Average loss: 3.4616\n",
      "Iteration: 1627; Percent complete: 40.7%; Average loss: 3.1423\n",
      "Iteration: 1628; Percent complete: 40.7%; Average loss: 3.2589\n",
      "Iteration: 1629; Percent complete: 40.7%; Average loss: 3.5174\n",
      "Iteration: 1630; Percent complete: 40.8%; Average loss: 3.3261\n",
      "Iteration: 1631; Percent complete: 40.8%; Average loss: 3.0754\n",
      "Iteration: 1632; Percent complete: 40.8%; Average loss: 3.2749\n",
      "Iteration: 1633; Percent complete: 40.8%; Average loss: 3.3269\n",
      "Iteration: 1634; Percent complete: 40.8%; Average loss: 3.3621\n",
      "Iteration: 1635; Percent complete: 40.9%; Average loss: 3.2311\n",
      "Iteration: 1636; Percent complete: 40.9%; Average loss: 3.1978\n",
      "Iteration: 1637; Percent complete: 40.9%; Average loss: 3.2275\n",
      "Iteration: 1638; Percent complete: 40.9%; Average loss: 3.3434\n",
      "Iteration: 1639; Percent complete: 41.0%; Average loss: 3.2730\n",
      "Iteration: 1640; Percent complete: 41.0%; Average loss: 3.2059\n",
      "Iteration: 1641; Percent complete: 41.0%; Average loss: 3.5691\n",
      "Iteration: 1642; Percent complete: 41.0%; Average loss: 3.1965\n",
      "Iteration: 1643; Percent complete: 41.1%; Average loss: 3.1673\n",
      "Iteration: 1644; Percent complete: 41.1%; Average loss: 3.3307\n",
      "Iteration: 1645; Percent complete: 41.1%; Average loss: 3.1539\n",
      "Iteration: 1646; Percent complete: 41.1%; Average loss: 3.1547\n",
      "Iteration: 1647; Percent complete: 41.2%; Average loss: 3.1970\n",
      "Iteration: 1648; Percent complete: 41.2%; Average loss: 3.2920\n",
      "Iteration: 1649; Percent complete: 41.2%; Average loss: 3.6301\n",
      "Iteration: 1650; Percent complete: 41.2%; Average loss: 3.3316\n",
      "Iteration: 1651; Percent complete: 41.3%; Average loss: 3.3826\n",
      "Iteration: 1652; Percent complete: 41.3%; Average loss: 3.1560\n",
      "Iteration: 1653; Percent complete: 41.3%; Average loss: 3.3843\n",
      "Iteration: 1654; Percent complete: 41.3%; Average loss: 3.1200\n",
      "Iteration: 1655; Percent complete: 41.4%; Average loss: 3.2709\n",
      "Iteration: 1656; Percent complete: 41.4%; Average loss: 3.2407\n",
      "Iteration: 1657; Percent complete: 41.4%; Average loss: 3.3628\n",
      "Iteration: 1658; Percent complete: 41.4%; Average loss: 3.5441\n",
      "Iteration: 1659; Percent complete: 41.5%; Average loss: 3.1979\n",
      "Iteration: 1660; Percent complete: 41.5%; Average loss: 3.0799\n",
      "Iteration: 1661; Percent complete: 41.5%; Average loss: 3.2393\n",
      "Iteration: 1662; Percent complete: 41.5%; Average loss: 3.3170\n",
      "Iteration: 1663; Percent complete: 41.6%; Average loss: 3.1911\n",
      "Iteration: 1664; Percent complete: 41.6%; Average loss: 3.3174\n",
      "Iteration: 1665; Percent complete: 41.6%; Average loss: 3.2659\n",
      "Iteration: 1666; Percent complete: 41.6%; Average loss: 3.0339\n",
      "Iteration: 1667; Percent complete: 41.7%; Average loss: 3.2297\n",
      "Iteration: 1668; Percent complete: 41.7%; Average loss: 3.2906\n",
      "Iteration: 1669; Percent complete: 41.7%; Average loss: 3.2319\n",
      "Iteration: 1670; Percent complete: 41.8%; Average loss: 3.1318\n",
      "Iteration: 1671; Percent complete: 41.8%; Average loss: 3.3216\n",
      "Iteration: 1672; Percent complete: 41.8%; Average loss: 3.2924\n",
      "Iteration: 1673; Percent complete: 41.8%; Average loss: 3.0284\n",
      "Iteration: 1674; Percent complete: 41.9%; Average loss: 3.3076\n",
      "Iteration: 1675; Percent complete: 41.9%; Average loss: 3.3069\n",
      "Iteration: 1676; Percent complete: 41.9%; Average loss: 3.3192\n",
      "Iteration: 1677; Percent complete: 41.9%; Average loss: 3.1583\n",
      "Iteration: 1678; Percent complete: 41.9%; Average loss: 3.1509\n",
      "Iteration: 1679; Percent complete: 42.0%; Average loss: 3.2582\n",
      "Iteration: 1680; Percent complete: 42.0%; Average loss: 3.1569\n",
      "Iteration: 1681; Percent complete: 42.0%; Average loss: 3.2004\n",
      "Iteration: 1682; Percent complete: 42.0%; Average loss: 3.1382\n",
      "Iteration: 1683; Percent complete: 42.1%; Average loss: 3.0273\n",
      "Iteration: 1684; Percent complete: 42.1%; Average loss: 3.4535\n",
      "Iteration: 1685; Percent complete: 42.1%; Average loss: 3.2532\n",
      "Iteration: 1686; Percent complete: 42.1%; Average loss: 3.0666\n",
      "Iteration: 1687; Percent complete: 42.2%; Average loss: 3.1688\n",
      "Iteration: 1688; Percent complete: 42.2%; Average loss: 3.2995\n",
      "Iteration: 1689; Percent complete: 42.2%; Average loss: 3.2881\n",
      "Iteration: 1690; Percent complete: 42.2%; Average loss: 3.1068\n",
      "Iteration: 1691; Percent complete: 42.3%; Average loss: 3.1598\n",
      "Iteration: 1692; Percent complete: 42.3%; Average loss: 3.3232\n",
      "Iteration: 1693; Percent complete: 42.3%; Average loss: 3.0550\n",
      "Iteration: 1694; Percent complete: 42.4%; Average loss: 3.0747\n",
      "Iteration: 1695; Percent complete: 42.4%; Average loss: 3.7363\n",
      "Iteration: 1696; Percent complete: 42.4%; Average loss: 3.2509\n",
      "Iteration: 1697; Percent complete: 42.4%; Average loss: 3.1144\n",
      "Iteration: 1698; Percent complete: 42.4%; Average loss: 3.2347\n",
      "Iteration: 1699; Percent complete: 42.5%; Average loss: 3.5217\n",
      "Iteration: 1700; Percent complete: 42.5%; Average loss: 2.9088\n",
      "Iteration: 1701; Percent complete: 42.5%; Average loss: 3.0741\n",
      "Iteration: 1702; Percent complete: 42.5%; Average loss: 3.3730\n",
      "Iteration: 1703; Percent complete: 42.6%; Average loss: 3.2973\n",
      "Iteration: 1704; Percent complete: 42.6%; Average loss: 3.1509\n",
      "Iteration: 1705; Percent complete: 42.6%; Average loss: 3.2802\n",
      "Iteration: 1706; Percent complete: 42.6%; Average loss: 3.3210\n",
      "Iteration: 1707; Percent complete: 42.7%; Average loss: 3.3020\n",
      "Iteration: 1708; Percent complete: 42.7%; Average loss: 3.4185\n",
      "Iteration: 1709; Percent complete: 42.7%; Average loss: 3.2796\n",
      "Iteration: 1710; Percent complete: 42.8%; Average loss: 3.3350\n",
      "Iteration: 1711; Percent complete: 42.8%; Average loss: 3.2451\n",
      "Iteration: 1712; Percent complete: 42.8%; Average loss: 3.3463\n",
      "Iteration: 1713; Percent complete: 42.8%; Average loss: 3.0524\n",
      "Iteration: 1714; Percent complete: 42.9%; Average loss: 3.3009\n",
      "Iteration: 1715; Percent complete: 42.9%; Average loss: 3.5757\n",
      "Iteration: 1716; Percent complete: 42.9%; Average loss: 3.2053\n",
      "Iteration: 1717; Percent complete: 42.9%; Average loss: 3.2960\n",
      "Iteration: 1718; Percent complete: 43.0%; Average loss: 3.2737\n",
      "Iteration: 1719; Percent complete: 43.0%; Average loss: 3.2134\n",
      "Iteration: 1720; Percent complete: 43.0%; Average loss: 3.5673\n",
      "Iteration: 1721; Percent complete: 43.0%; Average loss: 3.0836\n",
      "Iteration: 1722; Percent complete: 43.0%; Average loss: 3.0120\n",
      "Iteration: 1723; Percent complete: 43.1%; Average loss: 3.2745\n",
      "Iteration: 1724; Percent complete: 43.1%; Average loss: 3.0907\n",
      "Iteration: 1725; Percent complete: 43.1%; Average loss: 2.8622\n",
      "Iteration: 1726; Percent complete: 43.1%; Average loss: 3.2587\n",
      "Iteration: 1727; Percent complete: 43.2%; Average loss: 2.9937\n",
      "Iteration: 1728; Percent complete: 43.2%; Average loss: 3.2139\n",
      "Iteration: 1729; Percent complete: 43.2%; Average loss: 3.2263\n",
      "Iteration: 1730; Percent complete: 43.2%; Average loss: 3.3437\n",
      "Iteration: 1731; Percent complete: 43.3%; Average loss: 3.3069\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 1732; Percent complete: 43.3%; Average loss: 3.2480\n",
      "Iteration: 1733; Percent complete: 43.3%; Average loss: 3.1492\n",
      "Iteration: 1734; Percent complete: 43.4%; Average loss: 3.0898\n",
      "Iteration: 1735; Percent complete: 43.4%; Average loss: 3.2742\n",
      "Iteration: 1736; Percent complete: 43.4%; Average loss: 3.1834\n",
      "Iteration: 1737; Percent complete: 43.4%; Average loss: 3.1214\n",
      "Iteration: 1738; Percent complete: 43.5%; Average loss: 3.1737\n",
      "Iteration: 1739; Percent complete: 43.5%; Average loss: 3.2352\n",
      "Iteration: 1740; Percent complete: 43.5%; Average loss: 3.1357\n",
      "Iteration: 1741; Percent complete: 43.5%; Average loss: 3.0778\n",
      "Iteration: 1742; Percent complete: 43.5%; Average loss: 3.1339\n",
      "Iteration: 1743; Percent complete: 43.6%; Average loss: 3.1357\n",
      "Iteration: 1744; Percent complete: 43.6%; Average loss: 3.0243\n",
      "Iteration: 1745; Percent complete: 43.6%; Average loss: 3.0295\n",
      "Iteration: 1746; Percent complete: 43.6%; Average loss: 3.2777\n",
      "Iteration: 1747; Percent complete: 43.7%; Average loss: 3.0730\n",
      "Iteration: 1748; Percent complete: 43.7%; Average loss: 2.8881\n",
      "Iteration: 1749; Percent complete: 43.7%; Average loss: 3.2815\n",
      "Iteration: 1750; Percent complete: 43.8%; Average loss: 3.3402\n",
      "Iteration: 1751; Percent complete: 43.8%; Average loss: 3.1964\n",
      "Iteration: 1752; Percent complete: 43.8%; Average loss: 3.1660\n",
      "Iteration: 1753; Percent complete: 43.8%; Average loss: 3.3783\n",
      "Iteration: 1754; Percent complete: 43.9%; Average loss: 3.0902\n",
      "Iteration: 1755; Percent complete: 43.9%; Average loss: 3.5379\n",
      "Iteration: 1756; Percent complete: 43.9%; Average loss: 3.1963\n",
      "Iteration: 1757; Percent complete: 43.9%; Average loss: 3.2202\n",
      "Iteration: 1758; Percent complete: 44.0%; Average loss: 3.1931\n",
      "Iteration: 1759; Percent complete: 44.0%; Average loss: 3.0199\n",
      "Iteration: 1760; Percent complete: 44.0%; Average loss: 3.3082\n",
      "Iteration: 1761; Percent complete: 44.0%; Average loss: 3.0854\n",
      "Iteration: 1762; Percent complete: 44.0%; Average loss: 3.2958\n",
      "Iteration: 1763; Percent complete: 44.1%; Average loss: 3.5703\n",
      "Iteration: 1764; Percent complete: 44.1%; Average loss: 3.3230\n",
      "Iteration: 1765; Percent complete: 44.1%; Average loss: 3.2747\n",
      "Iteration: 1766; Percent complete: 44.1%; Average loss: 2.9970\n",
      "Iteration: 1767; Percent complete: 44.2%; Average loss: 3.3682\n",
      "Iteration: 1768; Percent complete: 44.2%; Average loss: 3.2372\n",
      "Iteration: 1769; Percent complete: 44.2%; Average loss: 3.3011\n",
      "Iteration: 1770; Percent complete: 44.2%; Average loss: 3.2383\n",
      "Iteration: 1771; Percent complete: 44.3%; Average loss: 3.3552\n",
      "Iteration: 1772; Percent complete: 44.3%; Average loss: 3.5326\n",
      "Iteration: 1773; Percent complete: 44.3%; Average loss: 3.3245\n",
      "Iteration: 1774; Percent complete: 44.4%; Average loss: 3.1031\n",
      "Iteration: 1775; Percent complete: 44.4%; Average loss: 3.5246\n",
      "Iteration: 1776; Percent complete: 44.4%; Average loss: 3.0462\n",
      "Iteration: 1777; Percent complete: 44.4%; Average loss: 3.1408\n",
      "Iteration: 1778; Percent complete: 44.5%; Average loss: 3.3515\n",
      "Iteration: 1779; Percent complete: 44.5%; Average loss: 3.1424\n",
      "Iteration: 1780; Percent complete: 44.5%; Average loss: 3.1473\n",
      "Iteration: 1781; Percent complete: 44.5%; Average loss: 3.2055\n",
      "Iteration: 1782; Percent complete: 44.5%; Average loss: 3.1222\n",
      "Iteration: 1783; Percent complete: 44.6%; Average loss: 3.1951\n",
      "Iteration: 1784; Percent complete: 44.6%; Average loss: 3.1777\n",
      "Iteration: 1785; Percent complete: 44.6%; Average loss: 3.1068\n",
      "Iteration: 1786; Percent complete: 44.6%; Average loss: 3.0681\n",
      "Iteration: 1787; Percent complete: 44.7%; Average loss: 2.9016\n",
      "Iteration: 1788; Percent complete: 44.7%; Average loss: 3.2329\n",
      "Iteration: 1789; Percent complete: 44.7%; Average loss: 3.4315\n",
      "Iteration: 1790; Percent complete: 44.8%; Average loss: 3.0262\n",
      "Iteration: 1791; Percent complete: 44.8%; Average loss: 3.3736\n",
      "Iteration: 1792; Percent complete: 44.8%; Average loss: 3.1990\n",
      "Iteration: 1793; Percent complete: 44.8%; Average loss: 3.2731\n",
      "Iteration: 1794; Percent complete: 44.9%; Average loss: 3.2390\n",
      "Iteration: 1795; Percent complete: 44.9%; Average loss: 3.0687\n",
      "Iteration: 1796; Percent complete: 44.9%; Average loss: 3.2491\n",
      "Iteration: 1797; Percent complete: 44.9%; Average loss: 3.1933\n",
      "Iteration: 1798; Percent complete: 45.0%; Average loss: 3.2698\n",
      "Iteration: 1799; Percent complete: 45.0%; Average loss: 3.2508\n",
      "Iteration: 1800; Percent complete: 45.0%; Average loss: 3.1900\n",
      "Iteration: 1801; Percent complete: 45.0%; Average loss: 3.2708\n",
      "Iteration: 1802; Percent complete: 45.1%; Average loss: 3.1724\n",
      "Iteration: 1803; Percent complete: 45.1%; Average loss: 3.1440\n",
      "Iteration: 1804; Percent complete: 45.1%; Average loss: 3.3069\n",
      "Iteration: 1805; Percent complete: 45.1%; Average loss: 2.7450\n",
      "Iteration: 1806; Percent complete: 45.1%; Average loss: 3.3440\n",
      "Iteration: 1807; Percent complete: 45.2%; Average loss: 3.3420\n",
      "Iteration: 1808; Percent complete: 45.2%; Average loss: 3.0721\n",
      "Iteration: 1809; Percent complete: 45.2%; Average loss: 3.3141\n",
      "Iteration: 1810; Percent complete: 45.2%; Average loss: 3.2671\n",
      "Iteration: 1811; Percent complete: 45.3%; Average loss: 3.2244\n",
      "Iteration: 1812; Percent complete: 45.3%; Average loss: 3.4840\n",
      "Iteration: 1813; Percent complete: 45.3%; Average loss: 2.9710\n",
      "Iteration: 1814; Percent complete: 45.4%; Average loss: 3.1809\n",
      "Iteration: 1815; Percent complete: 45.4%; Average loss: 3.1603\n",
      "Iteration: 1816; Percent complete: 45.4%; Average loss: 3.2115\n",
      "Iteration: 1817; Percent complete: 45.4%; Average loss: 3.3085\n",
      "Iteration: 1818; Percent complete: 45.5%; Average loss: 3.1211\n",
      "Iteration: 1819; Percent complete: 45.5%; Average loss: 3.1208\n",
      "Iteration: 1820; Percent complete: 45.5%; Average loss: 3.2616\n",
      "Iteration: 1821; Percent complete: 45.5%; Average loss: 3.2061\n",
      "Iteration: 1822; Percent complete: 45.6%; Average loss: 3.3749\n",
      "Iteration: 1823; Percent complete: 45.6%; Average loss: 3.0281\n",
      "Iteration: 1824; Percent complete: 45.6%; Average loss: 3.1600\n",
      "Iteration: 1825; Percent complete: 45.6%; Average loss: 3.0844\n",
      "Iteration: 1826; Percent complete: 45.6%; Average loss: 3.1333\n",
      "Iteration: 1827; Percent complete: 45.7%; Average loss: 3.2696\n",
      "Iteration: 1828; Percent complete: 45.7%; Average loss: 3.0776\n",
      "Iteration: 1829; Percent complete: 45.7%; Average loss: 3.2898\n",
      "Iteration: 1830; Percent complete: 45.8%; Average loss: 3.3326\n",
      "Iteration: 1831; Percent complete: 45.8%; Average loss: 3.0536\n",
      "Iteration: 1832; Percent complete: 45.8%; Average loss: 3.1755\n",
      "Iteration: 1833; Percent complete: 45.8%; Average loss: 3.4599\n",
      "Iteration: 1834; Percent complete: 45.9%; Average loss: 3.0722\n",
      "Iteration: 1835; Percent complete: 45.9%; Average loss: 3.1503\n",
      "Iteration: 1836; Percent complete: 45.9%; Average loss: 3.1194\n",
      "Iteration: 1837; Percent complete: 45.9%; Average loss: 3.3896\n",
      "Iteration: 1838; Percent complete: 46.0%; Average loss: 3.2763\n",
      "Iteration: 1839; Percent complete: 46.0%; Average loss: 3.3916\n",
      "Iteration: 1840; Percent complete: 46.0%; Average loss: 3.2177\n",
      "Iteration: 1841; Percent complete: 46.0%; Average loss: 3.0118\n",
      "Iteration: 1842; Percent complete: 46.1%; Average loss: 3.3754\n",
      "Iteration: 1843; Percent complete: 46.1%; Average loss: 3.1338\n",
      "Iteration: 1844; Percent complete: 46.1%; Average loss: 3.2972\n",
      "Iteration: 1845; Percent complete: 46.1%; Average loss: 3.1049\n",
      "Iteration: 1846; Percent complete: 46.2%; Average loss: 3.0662\n",
      "Iteration: 1847; Percent complete: 46.2%; Average loss: 3.0940\n",
      "Iteration: 1848; Percent complete: 46.2%; Average loss: 3.1799\n",
      "Iteration: 1849; Percent complete: 46.2%; Average loss: 3.0952\n",
      "Iteration: 1850; Percent complete: 46.2%; Average loss: 3.1539\n",
      "Iteration: 1851; Percent complete: 46.3%; Average loss: 3.1118\n",
      "Iteration: 1852; Percent complete: 46.3%; Average loss: 3.0527\n",
      "Iteration: 1853; Percent complete: 46.3%; Average loss: 3.3779\n",
      "Iteration: 1854; Percent complete: 46.4%; Average loss: 3.1952\n",
      "Iteration: 1855; Percent complete: 46.4%; Average loss: 3.2582\n",
      "Iteration: 1856; Percent complete: 46.4%; Average loss: 3.2663\n",
      "Iteration: 1857; Percent complete: 46.4%; Average loss: 3.3277\n",
      "Iteration: 1858; Percent complete: 46.5%; Average loss: 3.0695\n",
      "Iteration: 1859; Percent complete: 46.5%; Average loss: 3.3019\n",
      "Iteration: 1860; Percent complete: 46.5%; Average loss: 3.4514\n",
      "Iteration: 1861; Percent complete: 46.5%; Average loss: 3.3632\n",
      "Iteration: 1862; Percent complete: 46.6%; Average loss: 3.1203\n",
      "Iteration: 1863; Percent complete: 46.6%; Average loss: 2.9483\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 1864; Percent complete: 46.6%; Average loss: 3.1616\n",
      "Iteration: 1865; Percent complete: 46.6%; Average loss: 3.2903\n",
      "Iteration: 1866; Percent complete: 46.7%; Average loss: 3.4989\n",
      "Iteration: 1867; Percent complete: 46.7%; Average loss: 3.4667\n",
      "Iteration: 1868; Percent complete: 46.7%; Average loss: 3.0177\n",
      "Iteration: 1869; Percent complete: 46.7%; Average loss: 3.5301\n",
      "Iteration: 1870; Percent complete: 46.8%; Average loss: 3.2530\n",
      "Iteration: 1871; Percent complete: 46.8%; Average loss: 3.0920\n",
      "Iteration: 1872; Percent complete: 46.8%; Average loss: 3.0117\n",
      "Iteration: 1873; Percent complete: 46.8%; Average loss: 3.3537\n",
      "Iteration: 1874; Percent complete: 46.9%; Average loss: 3.1072\n",
      "Iteration: 1875; Percent complete: 46.9%; Average loss: 3.2346\n",
      "Iteration: 1876; Percent complete: 46.9%; Average loss: 3.1308\n",
      "Iteration: 1877; Percent complete: 46.9%; Average loss: 3.1428\n",
      "Iteration: 1878; Percent complete: 46.9%; Average loss: 3.2638\n",
      "Iteration: 1879; Percent complete: 47.0%; Average loss: 3.2219\n",
      "Iteration: 1880; Percent complete: 47.0%; Average loss: 3.2582\n",
      "Iteration: 1881; Percent complete: 47.0%; Average loss: 2.9554\n",
      "Iteration: 1882; Percent complete: 47.0%; Average loss: 3.1811\n",
      "Iteration: 1883; Percent complete: 47.1%; Average loss: 3.2872\n",
      "Iteration: 1884; Percent complete: 47.1%; Average loss: 3.1900\n",
      "Iteration: 1885; Percent complete: 47.1%; Average loss: 2.9435\n",
      "Iteration: 1886; Percent complete: 47.1%; Average loss: 3.1098\n",
      "Iteration: 1887; Percent complete: 47.2%; Average loss: 2.9626\n",
      "Iteration: 1888; Percent complete: 47.2%; Average loss: 3.3637\n",
      "Iteration: 1889; Percent complete: 47.2%; Average loss: 3.0320\n",
      "Iteration: 1890; Percent complete: 47.2%; Average loss: 2.9439\n",
      "Iteration: 1891; Percent complete: 47.3%; Average loss: 3.4728\n",
      "Iteration: 1892; Percent complete: 47.3%; Average loss: 3.1122\n",
      "Iteration: 1893; Percent complete: 47.3%; Average loss: 3.1421\n",
      "Iteration: 1894; Percent complete: 47.3%; Average loss: 3.0689\n",
      "Iteration: 1895; Percent complete: 47.4%; Average loss: 3.0993\n",
      "Iteration: 1896; Percent complete: 47.4%; Average loss: 3.2469\n",
      "Iteration: 1897; Percent complete: 47.4%; Average loss: 3.0455\n",
      "Iteration: 1898; Percent complete: 47.4%; Average loss: 3.1555\n",
      "Iteration: 1899; Percent complete: 47.5%; Average loss: 3.4848\n",
      "Iteration: 1900; Percent complete: 47.5%; Average loss: 3.0433\n",
      "Iteration: 1901; Percent complete: 47.5%; Average loss: 3.2887\n",
      "Iteration: 1902; Percent complete: 47.5%; Average loss: 3.1658\n",
      "Iteration: 1903; Percent complete: 47.6%; Average loss: 3.2461\n",
      "Iteration: 1904; Percent complete: 47.6%; Average loss: 3.1562\n",
      "Iteration: 1905; Percent complete: 47.6%; Average loss: 3.1803\n",
      "Iteration: 1906; Percent complete: 47.6%; Average loss: 3.1760\n",
      "Iteration: 1907; Percent complete: 47.7%; Average loss: 3.1876\n",
      "Iteration: 1908; Percent complete: 47.7%; Average loss: 3.3191\n",
      "Iteration: 1909; Percent complete: 47.7%; Average loss: 3.1078\n",
      "Iteration: 1910; Percent complete: 47.8%; Average loss: 3.4634\n",
      "Iteration: 1911; Percent complete: 47.8%; Average loss: 3.1402\n",
      "Iteration: 1912; Percent complete: 47.8%; Average loss: 3.1514\n",
      "Iteration: 1913; Percent complete: 47.8%; Average loss: 3.0192\n",
      "Iteration: 1914; Percent complete: 47.9%; Average loss: 3.2806\n",
      "Iteration: 1915; Percent complete: 47.9%; Average loss: 3.1443\n",
      "Iteration: 1916; Percent complete: 47.9%; Average loss: 3.2599\n",
      "Iteration: 1917; Percent complete: 47.9%; Average loss: 3.0563\n",
      "Iteration: 1918; Percent complete: 47.9%; Average loss: 3.0093\n",
      "Iteration: 1919; Percent complete: 48.0%; Average loss: 3.2144\n",
      "Iteration: 1920; Percent complete: 48.0%; Average loss: 3.3280\n",
      "Iteration: 1921; Percent complete: 48.0%; Average loss: 2.9464\n",
      "Iteration: 1922; Percent complete: 48.0%; Average loss: 3.1958\n",
      "Iteration: 1923; Percent complete: 48.1%; Average loss: 3.4456\n",
      "Iteration: 1924; Percent complete: 48.1%; Average loss: 2.9813\n",
      "Iteration: 1925; Percent complete: 48.1%; Average loss: 3.2209\n",
      "Iteration: 1926; Percent complete: 48.1%; Average loss: 3.0247\n",
      "Iteration: 1927; Percent complete: 48.2%; Average loss: 3.1559\n",
      "Iteration: 1928; Percent complete: 48.2%; Average loss: 3.0232\n",
      "Iteration: 1929; Percent complete: 48.2%; Average loss: 3.2733\n",
      "Iteration: 1930; Percent complete: 48.2%; Average loss: 2.9617\n",
      "Iteration: 1931; Percent complete: 48.3%; Average loss: 3.0685\n",
      "Iteration: 1932; Percent complete: 48.3%; Average loss: 3.1174\n",
      "Iteration: 1933; Percent complete: 48.3%; Average loss: 3.3913\n",
      "Iteration: 1934; Percent complete: 48.4%; Average loss: 3.1245\n",
      "Iteration: 1935; Percent complete: 48.4%; Average loss: 3.3199\n",
      "Iteration: 1936; Percent complete: 48.4%; Average loss: 3.1740\n",
      "Iteration: 1937; Percent complete: 48.4%; Average loss: 3.1693\n",
      "Iteration: 1938; Percent complete: 48.4%; Average loss: 3.0133\n",
      "Iteration: 1939; Percent complete: 48.5%; Average loss: 3.2931\n",
      "Iteration: 1940; Percent complete: 48.5%; Average loss: 3.1597\n",
      "Iteration: 1941; Percent complete: 48.5%; Average loss: 3.2785\n",
      "Iteration: 1942; Percent complete: 48.5%; Average loss: 3.2611\n",
      "Iteration: 1943; Percent complete: 48.6%; Average loss: 3.1247\n",
      "Iteration: 1944; Percent complete: 48.6%; Average loss: 3.1234\n",
      "Iteration: 1945; Percent complete: 48.6%; Average loss: 3.1025\n",
      "Iteration: 1946; Percent complete: 48.6%; Average loss: 3.1693\n",
      "Iteration: 1947; Percent complete: 48.7%; Average loss: 3.5490\n",
      "Iteration: 1948; Percent complete: 48.7%; Average loss: 3.0765\n",
      "Iteration: 1949; Percent complete: 48.7%; Average loss: 3.1955\n",
      "Iteration: 1950; Percent complete: 48.8%; Average loss: 3.1541\n",
      "Iteration: 1951; Percent complete: 48.8%; Average loss: 3.2226\n",
      "Iteration: 1952; Percent complete: 48.8%; Average loss: 3.1550\n",
      "Iteration: 1953; Percent complete: 48.8%; Average loss: 3.1118\n",
      "Iteration: 1954; Percent complete: 48.9%; Average loss: 3.3400\n",
      "Iteration: 1955; Percent complete: 48.9%; Average loss: 3.2872\n",
      "Iteration: 1956; Percent complete: 48.9%; Average loss: 3.2280\n",
      "Iteration: 1957; Percent complete: 48.9%; Average loss: 3.2221\n",
      "Iteration: 1958; Percent complete: 48.9%; Average loss: 3.0234\n",
      "Iteration: 1959; Percent complete: 49.0%; Average loss: 2.9378\n",
      "Iteration: 1960; Percent complete: 49.0%; Average loss: 3.1693\n",
      "Iteration: 1961; Percent complete: 49.0%; Average loss: 3.1437\n",
      "Iteration: 1962; Percent complete: 49.0%; Average loss: 3.0083\n",
      "Iteration: 1963; Percent complete: 49.1%; Average loss: 3.1076\n",
      "Iteration: 1964; Percent complete: 49.1%; Average loss: 3.3583\n",
      "Iteration: 1965; Percent complete: 49.1%; Average loss: 2.9069\n",
      "Iteration: 1966; Percent complete: 49.1%; Average loss: 3.5110\n",
      "Iteration: 1967; Percent complete: 49.2%; Average loss: 3.5528\n",
      "Iteration: 1968; Percent complete: 49.2%; Average loss: 3.3054\n",
      "Iteration: 1969; Percent complete: 49.2%; Average loss: 3.0720\n",
      "Iteration: 1970; Percent complete: 49.2%; Average loss: 3.0433\n",
      "Iteration: 1971; Percent complete: 49.3%; Average loss: 3.2247\n",
      "Iteration: 1972; Percent complete: 49.3%; Average loss: 3.4000\n",
      "Iteration: 1973; Percent complete: 49.3%; Average loss: 3.0563\n",
      "Iteration: 1974; Percent complete: 49.4%; Average loss: 3.0068\n",
      "Iteration: 1975; Percent complete: 49.4%; Average loss: 2.7998\n",
      "Iteration: 1976; Percent complete: 49.4%; Average loss: 3.2492\n",
      "Iteration: 1977; Percent complete: 49.4%; Average loss: 3.1628\n",
      "Iteration: 1978; Percent complete: 49.5%; Average loss: 3.1124\n",
      "Iteration: 1979; Percent complete: 49.5%; Average loss: 3.1490\n",
      "Iteration: 1980; Percent complete: 49.5%; Average loss: 3.3870\n",
      "Iteration: 1981; Percent complete: 49.5%; Average loss: 2.7363\n",
      "Iteration: 1982; Percent complete: 49.5%; Average loss: 3.0281\n",
      "Iteration: 1983; Percent complete: 49.6%; Average loss: 3.0659\n",
      "Iteration: 1984; Percent complete: 49.6%; Average loss: 3.1057\n",
      "Iteration: 1985; Percent complete: 49.6%; Average loss: 3.0873\n",
      "Iteration: 1986; Percent complete: 49.6%; Average loss: 3.1281\n",
      "Iteration: 1987; Percent complete: 49.7%; Average loss: 3.2584\n",
      "Iteration: 1988; Percent complete: 49.7%; Average loss: 3.1041\n",
      "Iteration: 1989; Percent complete: 49.7%; Average loss: 3.4596\n",
      "Iteration: 1990; Percent complete: 49.8%; Average loss: 3.1387\n",
      "Iteration: 1991; Percent complete: 49.8%; Average loss: 3.1192\n",
      "Iteration: 1992; Percent complete: 49.8%; Average loss: 2.9165\n",
      "Iteration: 1993; Percent complete: 49.8%; Average loss: 3.3087\n",
      "Iteration: 1994; Percent complete: 49.9%; Average loss: 3.3624\n",
      "Iteration: 1995; Percent complete: 49.9%; Average loss: 3.1485\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 1996; Percent complete: 49.9%; Average loss: 2.8253\n",
      "Iteration: 1997; Percent complete: 49.9%; Average loss: 2.9372\n",
      "Iteration: 1998; Percent complete: 50.0%; Average loss: 3.1092\n",
      "Iteration: 1999; Percent complete: 50.0%; Average loss: 2.7962\n",
      "Iteration: 2000; Percent complete: 50.0%; Average loss: 3.0520\n",
      "Iteration: 2001; Percent complete: 50.0%; Average loss: 3.0636\n",
      "Iteration: 2002; Percent complete: 50.0%; Average loss: 3.1090\n",
      "Iteration: 2003; Percent complete: 50.1%; Average loss: 3.2714\n",
      "Iteration: 2004; Percent complete: 50.1%; Average loss: 3.0281\n",
      "Iteration: 2005; Percent complete: 50.1%; Average loss: 3.3000\n",
      "Iteration: 2006; Percent complete: 50.1%; Average loss: 3.0249\n",
      "Iteration: 2007; Percent complete: 50.2%; Average loss: 3.0493\n",
      "Iteration: 2008; Percent complete: 50.2%; Average loss: 3.1930\n",
      "Iteration: 2009; Percent complete: 50.2%; Average loss: 2.9609\n",
      "Iteration: 2010; Percent complete: 50.2%; Average loss: 3.0445\n",
      "Iteration: 2011; Percent complete: 50.3%; Average loss: 3.2767\n",
      "Iteration: 2012; Percent complete: 50.3%; Average loss: 3.0747\n",
      "Iteration: 2013; Percent complete: 50.3%; Average loss: 3.0637\n",
      "Iteration: 2014; Percent complete: 50.3%; Average loss: 3.3116\n",
      "Iteration: 2015; Percent complete: 50.4%; Average loss: 3.4703\n",
      "Iteration: 2016; Percent complete: 50.4%; Average loss: 3.4820\n",
      "Iteration: 2017; Percent complete: 50.4%; Average loss: 3.0619\n",
      "Iteration: 2018; Percent complete: 50.4%; Average loss: 3.1061\n",
      "Iteration: 2019; Percent complete: 50.5%; Average loss: 3.0572\n",
      "Iteration: 2020; Percent complete: 50.5%; Average loss: 3.0876\n",
      "Iteration: 2021; Percent complete: 50.5%; Average loss: 3.3965\n",
      "Iteration: 2022; Percent complete: 50.5%; Average loss: 3.2668\n",
      "Iteration: 2023; Percent complete: 50.6%; Average loss: 3.1816\n",
      "Iteration: 2024; Percent complete: 50.6%; Average loss: 3.2614\n",
      "Iteration: 2025; Percent complete: 50.6%; Average loss: 3.3656\n",
      "Iteration: 2026; Percent complete: 50.6%; Average loss: 3.0531\n",
      "Iteration: 2027; Percent complete: 50.7%; Average loss: 3.2187\n",
      "Iteration: 2028; Percent complete: 50.7%; Average loss: 2.9665\n",
      "Iteration: 2029; Percent complete: 50.7%; Average loss: 3.2580\n",
      "Iteration: 2030; Percent complete: 50.7%; Average loss: 3.1186\n",
      "Iteration: 2031; Percent complete: 50.8%; Average loss: 3.5083\n",
      "Iteration: 2032; Percent complete: 50.8%; Average loss: 2.9700\n",
      "Iteration: 2033; Percent complete: 50.8%; Average loss: 3.1693\n",
      "Iteration: 2034; Percent complete: 50.8%; Average loss: 2.8075\n",
      "Iteration: 2035; Percent complete: 50.9%; Average loss: 3.3989\n",
      "Iteration: 2036; Percent complete: 50.9%; Average loss: 3.1810\n",
      "Iteration: 2037; Percent complete: 50.9%; Average loss: 3.2461\n",
      "Iteration: 2038; Percent complete: 50.9%; Average loss: 2.8279\n",
      "Iteration: 2039; Percent complete: 51.0%; Average loss: 3.1273\n",
      "Iteration: 2040; Percent complete: 51.0%; Average loss: 3.0379\n",
      "Iteration: 2041; Percent complete: 51.0%; Average loss: 3.1754\n",
      "Iteration: 2042; Percent complete: 51.0%; Average loss: 3.0137\n",
      "Iteration: 2043; Percent complete: 51.1%; Average loss: 3.3507\n",
      "Iteration: 2044; Percent complete: 51.1%; Average loss: 3.1514\n",
      "Iteration: 2045; Percent complete: 51.1%; Average loss: 3.0233\n",
      "Iteration: 2046; Percent complete: 51.1%; Average loss: 3.0993\n",
      "Iteration: 2047; Percent complete: 51.2%; Average loss: 3.0999\n",
      "Iteration: 2048; Percent complete: 51.2%; Average loss: 3.2891\n",
      "Iteration: 2049; Percent complete: 51.2%; Average loss: 2.9267\n",
      "Iteration: 2050; Percent complete: 51.2%; Average loss: 3.3900\n",
      "Iteration: 2051; Percent complete: 51.3%; Average loss: 3.1565\n",
      "Iteration: 2052; Percent complete: 51.3%; Average loss: 3.3670\n",
      "Iteration: 2053; Percent complete: 51.3%; Average loss: 3.0059\n",
      "Iteration: 2054; Percent complete: 51.3%; Average loss: 3.1821\n",
      "Iteration: 2055; Percent complete: 51.4%; Average loss: 3.1567\n",
      "Iteration: 2056; Percent complete: 51.4%; Average loss: 3.1317\n",
      "Iteration: 2057; Percent complete: 51.4%; Average loss: 3.0425\n",
      "Iteration: 2058; Percent complete: 51.4%; Average loss: 3.0553\n",
      "Iteration: 2059; Percent complete: 51.5%; Average loss: 3.0917\n",
      "Iteration: 2060; Percent complete: 51.5%; Average loss: 3.1812\n",
      "Iteration: 2061; Percent complete: 51.5%; Average loss: 3.0413\n",
      "Iteration: 2062; Percent complete: 51.5%; Average loss: 3.0507\n",
      "Iteration: 2063; Percent complete: 51.6%; Average loss: 3.2332\n",
      "Iteration: 2064; Percent complete: 51.6%; Average loss: 3.1252\n",
      "Iteration: 2065; Percent complete: 51.6%; Average loss: 3.0891\n",
      "Iteration: 2066; Percent complete: 51.6%; Average loss: 3.1776\n",
      "Iteration: 2067; Percent complete: 51.7%; Average loss: 3.1419\n",
      "Iteration: 2068; Percent complete: 51.7%; Average loss: 3.0089\n",
      "Iteration: 2069; Percent complete: 51.7%; Average loss: 3.1744\n",
      "Iteration: 2070; Percent complete: 51.7%; Average loss: 2.9534\n",
      "Iteration: 2071; Percent complete: 51.8%; Average loss: 3.4844\n",
      "Iteration: 2072; Percent complete: 51.8%; Average loss: 2.9668\n",
      "Iteration: 2073; Percent complete: 51.8%; Average loss: 2.9922\n",
      "Iteration: 2074; Percent complete: 51.8%; Average loss: 3.0653\n",
      "Iteration: 2075; Percent complete: 51.9%; Average loss: 2.9835\n",
      "Iteration: 2076; Percent complete: 51.9%; Average loss: 3.2020\n",
      "Iteration: 2077; Percent complete: 51.9%; Average loss: 3.0022\n",
      "Iteration: 2078; Percent complete: 51.9%; Average loss: 3.0137\n",
      "Iteration: 2079; Percent complete: 52.0%; Average loss: 3.4220\n",
      "Iteration: 2080; Percent complete: 52.0%; Average loss: 3.2149\n",
      "Iteration: 2081; Percent complete: 52.0%; Average loss: 3.0511\n",
      "Iteration: 2082; Percent complete: 52.0%; Average loss: 3.2142\n",
      "Iteration: 2083; Percent complete: 52.1%; Average loss: 3.1522\n",
      "Iteration: 2084; Percent complete: 52.1%; Average loss: 2.9065\n",
      "Iteration: 2085; Percent complete: 52.1%; Average loss: 3.1268\n",
      "Iteration: 2086; Percent complete: 52.1%; Average loss: 3.1783\n",
      "Iteration: 2087; Percent complete: 52.2%; Average loss: 3.0808\n",
      "Iteration: 2088; Percent complete: 52.2%; Average loss: 2.9641\n",
      "Iteration: 2089; Percent complete: 52.2%; Average loss: 3.1087\n",
      "Iteration: 2090; Percent complete: 52.2%; Average loss: 3.0398\n",
      "Iteration: 2091; Percent complete: 52.3%; Average loss: 3.2119\n",
      "Iteration: 2092; Percent complete: 52.3%; Average loss: 3.3899\n",
      "Iteration: 2093; Percent complete: 52.3%; Average loss: 3.1051\n",
      "Iteration: 2094; Percent complete: 52.3%; Average loss: 3.3474\n",
      "Iteration: 2095; Percent complete: 52.4%; Average loss: 2.8940\n",
      "Iteration: 2096; Percent complete: 52.4%; Average loss: 2.9946\n",
      "Iteration: 2097; Percent complete: 52.4%; Average loss: 3.1518\n",
      "Iteration: 2098; Percent complete: 52.4%; Average loss: 3.2231\n",
      "Iteration: 2099; Percent complete: 52.5%; Average loss: 3.1027\n",
      "Iteration: 2100; Percent complete: 52.5%; Average loss: 3.1452\n",
      "Iteration: 2101; Percent complete: 52.5%; Average loss: 3.0388\n",
      "Iteration: 2102; Percent complete: 52.5%; Average loss: 3.1758\n",
      "Iteration: 2103; Percent complete: 52.6%; Average loss: 3.1307\n",
      "Iteration: 2104; Percent complete: 52.6%; Average loss: 3.0952\n",
      "Iteration: 2105; Percent complete: 52.6%; Average loss: 3.0300\n",
      "Iteration: 2106; Percent complete: 52.6%; Average loss: 3.5266\n",
      "Iteration: 2107; Percent complete: 52.7%; Average loss: 3.0783\n",
      "Iteration: 2108; Percent complete: 52.7%; Average loss: 3.0486\n",
      "Iteration: 2109; Percent complete: 52.7%; Average loss: 3.1319\n",
      "Iteration: 2110; Percent complete: 52.8%; Average loss: 3.3078\n",
      "Iteration: 2111; Percent complete: 52.8%; Average loss: 3.1503\n",
      "Iteration: 2112; Percent complete: 52.8%; Average loss: 3.1121\n",
      "Iteration: 2113; Percent complete: 52.8%; Average loss: 3.0434\n",
      "Iteration: 2114; Percent complete: 52.8%; Average loss: 3.2168\n",
      "Iteration: 2115; Percent complete: 52.9%; Average loss: 2.9298\n",
      "Iteration: 2116; Percent complete: 52.9%; Average loss: 3.2146\n",
      "Iteration: 2117; Percent complete: 52.9%; Average loss: 3.0634\n",
      "Iteration: 2118; Percent complete: 52.9%; Average loss: 2.9178\n",
      "Iteration: 2119; Percent complete: 53.0%; Average loss: 3.0361\n",
      "Iteration: 2120; Percent complete: 53.0%; Average loss: 2.9842\n",
      "Iteration: 2121; Percent complete: 53.0%; Average loss: 3.1554\n",
      "Iteration: 2122; Percent complete: 53.0%; Average loss: 3.0767\n",
      "Iteration: 2123; Percent complete: 53.1%; Average loss: 3.3452\n",
      "Iteration: 2124; Percent complete: 53.1%; Average loss: 3.2891\n",
      "Iteration: 2125; Percent complete: 53.1%; Average loss: 3.3575\n",
      "Iteration: 2126; Percent complete: 53.1%; Average loss: 3.1351\n",
      "Iteration: 2127; Percent complete: 53.2%; Average loss: 3.2296\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 2128; Percent complete: 53.2%; Average loss: 3.0957\n",
      "Iteration: 2129; Percent complete: 53.2%; Average loss: 3.2176\n",
      "Iteration: 2130; Percent complete: 53.2%; Average loss: 3.3402\n",
      "Iteration: 2131; Percent complete: 53.3%; Average loss: 2.9304\n",
      "Iteration: 2132; Percent complete: 53.3%; Average loss: 2.9619\n",
      "Iteration: 2133; Percent complete: 53.3%; Average loss: 2.9218\n",
      "Iteration: 2134; Percent complete: 53.3%; Average loss: 3.2347\n",
      "Iteration: 2135; Percent complete: 53.4%; Average loss: 3.1117\n",
      "Iteration: 2136; Percent complete: 53.4%; Average loss: 2.8136\n",
      "Iteration: 2137; Percent complete: 53.4%; Average loss: 2.9637\n",
      "Iteration: 2138; Percent complete: 53.4%; Average loss: 3.2667\n",
      "Iteration: 2139; Percent complete: 53.5%; Average loss: 3.1894\n",
      "Iteration: 2140; Percent complete: 53.5%; Average loss: 3.1748\n",
      "Iteration: 2141; Percent complete: 53.5%; Average loss: 3.0270\n",
      "Iteration: 2142; Percent complete: 53.5%; Average loss: 3.0764\n",
      "Iteration: 2143; Percent complete: 53.6%; Average loss: 2.9716\n",
      "Iteration: 2144; Percent complete: 53.6%; Average loss: 3.0536\n",
      "Iteration: 2145; Percent complete: 53.6%; Average loss: 3.0419\n",
      "Iteration: 2146; Percent complete: 53.6%; Average loss: 3.0319\n",
      "Iteration: 2147; Percent complete: 53.7%; Average loss: 3.1442\n",
      "Iteration: 2148; Percent complete: 53.7%; Average loss: 3.1904\n",
      "Iteration: 2149; Percent complete: 53.7%; Average loss: 2.9265\n",
      "Iteration: 2150; Percent complete: 53.8%; Average loss: 3.1884\n",
      "Iteration: 2151; Percent complete: 53.8%; Average loss: 3.0456\n",
      "Iteration: 2152; Percent complete: 53.8%; Average loss: 3.0806\n",
      "Iteration: 2153; Percent complete: 53.8%; Average loss: 3.1309\n",
      "Iteration: 2154; Percent complete: 53.8%; Average loss: 3.0645\n",
      "Iteration: 2155; Percent complete: 53.9%; Average loss: 3.0437\n",
      "Iteration: 2156; Percent complete: 53.9%; Average loss: 2.9674\n",
      "Iteration: 2157; Percent complete: 53.9%; Average loss: 3.2295\n",
      "Iteration: 2158; Percent complete: 53.9%; Average loss: 2.9165\n",
      "Iteration: 2159; Percent complete: 54.0%; Average loss: 3.0341\n",
      "Iteration: 2160; Percent complete: 54.0%; Average loss: 3.0665\n",
      "Iteration: 2161; Percent complete: 54.0%; Average loss: 3.0640\n",
      "Iteration: 2162; Percent complete: 54.0%; Average loss: 2.9832\n",
      "Iteration: 2163; Percent complete: 54.1%; Average loss: 2.9830\n",
      "Iteration: 2164; Percent complete: 54.1%; Average loss: 3.2766\n",
      "Iteration: 2165; Percent complete: 54.1%; Average loss: 3.4706\n",
      "Iteration: 2166; Percent complete: 54.1%; Average loss: 3.0885\n",
      "Iteration: 2167; Percent complete: 54.2%; Average loss: 3.0087\n",
      "Iteration: 2168; Percent complete: 54.2%; Average loss: 2.9126\n",
      "Iteration: 2169; Percent complete: 54.2%; Average loss: 3.1163\n",
      "Iteration: 2170; Percent complete: 54.2%; Average loss: 3.1639\n",
      "Iteration: 2171; Percent complete: 54.3%; Average loss: 3.1178\n",
      "Iteration: 2172; Percent complete: 54.3%; Average loss: 3.0308\n",
      "Iteration: 2173; Percent complete: 54.3%; Average loss: 2.9080\n",
      "Iteration: 2174; Percent complete: 54.4%; Average loss: 3.0841\n",
      "Iteration: 2175; Percent complete: 54.4%; Average loss: 3.1448\n",
      "Iteration: 2176; Percent complete: 54.4%; Average loss: 3.0038\n",
      "Iteration: 2177; Percent complete: 54.4%; Average loss: 2.9332\n",
      "Iteration: 2178; Percent complete: 54.4%; Average loss: 3.2487\n",
      "Iteration: 2179; Percent complete: 54.5%; Average loss: 3.3302\n",
      "Iteration: 2180; Percent complete: 54.5%; Average loss: 3.3358\n",
      "Iteration: 2181; Percent complete: 54.5%; Average loss: 3.0805\n",
      "Iteration: 2182; Percent complete: 54.5%; Average loss: 3.0991\n",
      "Iteration: 2183; Percent complete: 54.6%; Average loss: 3.1140\n",
      "Iteration: 2184; Percent complete: 54.6%; Average loss: 2.8441\n",
      "Iteration: 2185; Percent complete: 54.6%; Average loss: 3.1119\n",
      "Iteration: 2186; Percent complete: 54.6%; Average loss: 3.0231\n",
      "Iteration: 2187; Percent complete: 54.7%; Average loss: 3.1488\n",
      "Iteration: 2188; Percent complete: 54.7%; Average loss: 3.0155\n",
      "Iteration: 2189; Percent complete: 54.7%; Average loss: 2.8417\n",
      "Iteration: 2190; Percent complete: 54.8%; Average loss: 2.9217\n",
      "Iteration: 2191; Percent complete: 54.8%; Average loss: 3.1560\n",
      "Iteration: 2192; Percent complete: 54.8%; Average loss: 3.1118\n",
      "Iteration: 2193; Percent complete: 54.8%; Average loss: 2.9251\n",
      "Iteration: 2194; Percent complete: 54.9%; Average loss: 2.8844\n",
      "Iteration: 2195; Percent complete: 54.9%; Average loss: 3.3356\n",
      "Iteration: 2196; Percent complete: 54.9%; Average loss: 3.0708\n",
      "Iteration: 2197; Percent complete: 54.9%; Average loss: 2.8815\n",
      "Iteration: 2198; Percent complete: 54.9%; Average loss: 3.2200\n",
      "Iteration: 2199; Percent complete: 55.0%; Average loss: 3.0042\n",
      "Iteration: 2200; Percent complete: 55.0%; Average loss: 2.8186\n",
      "Iteration: 2201; Percent complete: 55.0%; Average loss: 2.9785\n",
      "Iteration: 2202; Percent complete: 55.0%; Average loss: 3.0514\n",
      "Iteration: 2203; Percent complete: 55.1%; Average loss: 3.0784\n",
      "Iteration: 2204; Percent complete: 55.1%; Average loss: 3.0661\n",
      "Iteration: 2205; Percent complete: 55.1%; Average loss: 3.0281\n",
      "Iteration: 2206; Percent complete: 55.1%; Average loss: 2.9824\n",
      "Iteration: 2207; Percent complete: 55.2%; Average loss: 3.3206\n",
      "Iteration: 2208; Percent complete: 55.2%; Average loss: 3.1211\n",
      "Iteration: 2209; Percent complete: 55.2%; Average loss: 2.9521\n",
      "Iteration: 2210; Percent complete: 55.2%; Average loss: 3.0901\n",
      "Iteration: 2211; Percent complete: 55.3%; Average loss: 2.8699\n",
      "Iteration: 2212; Percent complete: 55.3%; Average loss: 2.8252\n",
      "Iteration: 2213; Percent complete: 55.3%; Average loss: 3.1392\n",
      "Iteration: 2214; Percent complete: 55.4%; Average loss: 3.0809\n",
      "Iteration: 2215; Percent complete: 55.4%; Average loss: 3.2238\n",
      "Iteration: 2216; Percent complete: 55.4%; Average loss: 3.0536\n",
      "Iteration: 2217; Percent complete: 55.4%; Average loss: 3.0287\n",
      "Iteration: 2218; Percent complete: 55.5%; Average loss: 3.2313\n",
      "Iteration: 2219; Percent complete: 55.5%; Average loss: 3.0623\n",
      "Iteration: 2220; Percent complete: 55.5%; Average loss: 3.0377\n",
      "Iteration: 2221; Percent complete: 55.5%; Average loss: 3.2152\n",
      "Iteration: 2222; Percent complete: 55.5%; Average loss: 3.1769\n",
      "Iteration: 2223; Percent complete: 55.6%; Average loss: 3.1444\n",
      "Iteration: 2224; Percent complete: 55.6%; Average loss: 3.0113\n",
      "Iteration: 2225; Percent complete: 55.6%; Average loss: 2.8788\n",
      "Iteration: 2226; Percent complete: 55.6%; Average loss: 3.1759\n",
      "Iteration: 2227; Percent complete: 55.7%; Average loss: 3.1356\n",
      "Iteration: 2228; Percent complete: 55.7%; Average loss: 3.2103\n",
      "Iteration: 2229; Percent complete: 55.7%; Average loss: 3.1545\n",
      "Iteration: 2230; Percent complete: 55.8%; Average loss: 3.2257\n",
      "Iteration: 2231; Percent complete: 55.8%; Average loss: 3.1210\n",
      "Iteration: 2232; Percent complete: 55.8%; Average loss: 3.0957\n",
      "Iteration: 2233; Percent complete: 55.8%; Average loss: 3.0950\n",
      "Iteration: 2234; Percent complete: 55.9%; Average loss: 3.0413\n",
      "Iteration: 2235; Percent complete: 55.9%; Average loss: 3.3346\n",
      "Iteration: 2236; Percent complete: 55.9%; Average loss: 3.1831\n",
      "Iteration: 2237; Percent complete: 55.9%; Average loss: 3.1622\n",
      "Iteration: 2238; Percent complete: 56.0%; Average loss: 3.0160\n",
      "Iteration: 2239; Percent complete: 56.0%; Average loss: 3.0028\n",
      "Iteration: 2240; Percent complete: 56.0%; Average loss: 3.1374\n",
      "Iteration: 2241; Percent complete: 56.0%; Average loss: 2.7856\n",
      "Iteration: 2242; Percent complete: 56.0%; Average loss: 3.1595\n",
      "Iteration: 2243; Percent complete: 56.1%; Average loss: 2.7973\n",
      "Iteration: 2244; Percent complete: 56.1%; Average loss: 3.1148\n",
      "Iteration: 2245; Percent complete: 56.1%; Average loss: 3.3998\n",
      "Iteration: 2246; Percent complete: 56.1%; Average loss: 3.0165\n",
      "Iteration: 2247; Percent complete: 56.2%; Average loss: 3.0597\n",
      "Iteration: 2248; Percent complete: 56.2%; Average loss: 3.2235\n",
      "Iteration: 2249; Percent complete: 56.2%; Average loss: 3.0959\n",
      "Iteration: 2250; Percent complete: 56.2%; Average loss: 3.1950\n",
      "Iteration: 2251; Percent complete: 56.3%; Average loss: 2.9283\n",
      "Iteration: 2252; Percent complete: 56.3%; Average loss: 3.1326\n",
      "Iteration: 2253; Percent complete: 56.3%; Average loss: 3.2507\n",
      "Iteration: 2254; Percent complete: 56.4%; Average loss: 3.1887\n",
      "Iteration: 2255; Percent complete: 56.4%; Average loss: 3.0272\n",
      "Iteration: 2256; Percent complete: 56.4%; Average loss: 3.0210\n",
      "Iteration: 2257; Percent complete: 56.4%; Average loss: 3.0851\n",
      "Iteration: 2258; Percent complete: 56.5%; Average loss: 3.0051\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 2259; Percent complete: 56.5%; Average loss: 2.9584\n",
      "Iteration: 2260; Percent complete: 56.5%; Average loss: 2.9202\n",
      "Iteration: 2261; Percent complete: 56.5%; Average loss: 2.9951\n",
      "Iteration: 2262; Percent complete: 56.5%; Average loss: 2.8742\n",
      "Iteration: 2263; Percent complete: 56.6%; Average loss: 3.0455\n",
      "Iteration: 2264; Percent complete: 56.6%; Average loss: 3.0844\n",
      "Iteration: 2265; Percent complete: 56.6%; Average loss: 3.0843\n",
      "Iteration: 2266; Percent complete: 56.6%; Average loss: 3.3858\n",
      "Iteration: 2267; Percent complete: 56.7%; Average loss: 2.9059\n",
      "Iteration: 2268; Percent complete: 56.7%; Average loss: 3.0451\n",
      "Iteration: 2269; Percent complete: 56.7%; Average loss: 3.0644\n",
      "Iteration: 2270; Percent complete: 56.8%; Average loss: 3.4348\n",
      "Iteration: 2271; Percent complete: 56.8%; Average loss: 3.1560\n",
      "Iteration: 2272; Percent complete: 56.8%; Average loss: 3.1899\n",
      "Iteration: 2273; Percent complete: 56.8%; Average loss: 3.0485\n",
      "Iteration: 2274; Percent complete: 56.9%; Average loss: 3.2902\n",
      "Iteration: 2275; Percent complete: 56.9%; Average loss: 3.2490\n",
      "Iteration: 2276; Percent complete: 56.9%; Average loss: 3.1044\n",
      "Iteration: 2277; Percent complete: 56.9%; Average loss: 3.2537\n",
      "Iteration: 2278; Percent complete: 57.0%; Average loss: 3.0851\n",
      "Iteration: 2279; Percent complete: 57.0%; Average loss: 3.1186\n",
      "Iteration: 2280; Percent complete: 57.0%; Average loss: 2.9921\n",
      "Iteration: 2281; Percent complete: 57.0%; Average loss: 3.1382\n",
      "Iteration: 2282; Percent complete: 57.0%; Average loss: 2.9706\n",
      "Iteration: 2283; Percent complete: 57.1%; Average loss: 3.1208\n",
      "Iteration: 2284; Percent complete: 57.1%; Average loss: 3.1331\n",
      "Iteration: 2285; Percent complete: 57.1%; Average loss: 2.9233\n",
      "Iteration: 2286; Percent complete: 57.1%; Average loss: 3.1421\n",
      "Iteration: 2287; Percent complete: 57.2%; Average loss: 2.8935\n",
      "Iteration: 2288; Percent complete: 57.2%; Average loss: 3.0808\n",
      "Iteration: 2289; Percent complete: 57.2%; Average loss: 3.1042\n",
      "Iteration: 2290; Percent complete: 57.2%; Average loss: 3.3060\n",
      "Iteration: 2291; Percent complete: 57.3%; Average loss: 3.2389\n",
      "Iteration: 2292; Percent complete: 57.3%; Average loss: 3.0909\n",
      "Iteration: 2293; Percent complete: 57.3%; Average loss: 3.2315\n",
      "Iteration: 2294; Percent complete: 57.4%; Average loss: 3.0652\n",
      "Iteration: 2295; Percent complete: 57.4%; Average loss: 3.1876\n",
      "Iteration: 2296; Percent complete: 57.4%; Average loss: 2.8685\n",
      "Iteration: 2297; Percent complete: 57.4%; Average loss: 2.9947\n",
      "Iteration: 2298; Percent complete: 57.5%; Average loss: 3.0249\n",
      "Iteration: 2299; Percent complete: 57.5%; Average loss: 3.1224\n",
      "Iteration: 2300; Percent complete: 57.5%; Average loss: 3.3871\n",
      "Iteration: 2301; Percent complete: 57.5%; Average loss: 3.0080\n",
      "Iteration: 2302; Percent complete: 57.6%; Average loss: 2.8149\n",
      "Iteration: 2303; Percent complete: 57.6%; Average loss: 3.0485\n",
      "Iteration: 2304; Percent complete: 57.6%; Average loss: 3.0341\n",
      "Iteration: 2305; Percent complete: 57.6%; Average loss: 3.2012\n",
      "Iteration: 2306; Percent complete: 57.6%; Average loss: 3.1061\n",
      "Iteration: 2307; Percent complete: 57.7%; Average loss: 3.1557\n",
      "Iteration: 2308; Percent complete: 57.7%; Average loss: 3.2177\n",
      "Iteration: 2309; Percent complete: 57.7%; Average loss: 3.0274\n",
      "Iteration: 2310; Percent complete: 57.8%; Average loss: 2.9469\n",
      "Iteration: 2311; Percent complete: 57.8%; Average loss: 3.0915\n",
      "Iteration: 2312; Percent complete: 57.8%; Average loss: 2.9099\n",
      "Iteration: 2313; Percent complete: 57.8%; Average loss: 3.0121\n",
      "Iteration: 2314; Percent complete: 57.9%; Average loss: 2.9678\n",
      "Iteration: 2315; Percent complete: 57.9%; Average loss: 3.0621\n",
      "Iteration: 2316; Percent complete: 57.9%; Average loss: 3.2086\n",
      "Iteration: 2317; Percent complete: 57.9%; Average loss: 3.3552\n",
      "Iteration: 2318; Percent complete: 58.0%; Average loss: 2.9763\n",
      "Iteration: 2319; Percent complete: 58.0%; Average loss: 3.2436\n",
      "Iteration: 2320; Percent complete: 58.0%; Average loss: 3.0460\n",
      "Iteration: 2321; Percent complete: 58.0%; Average loss: 2.9289\n",
      "Iteration: 2322; Percent complete: 58.1%; Average loss: 3.1305\n",
      "Iteration: 2323; Percent complete: 58.1%; Average loss: 3.2794\n",
      "Iteration: 2324; Percent complete: 58.1%; Average loss: 3.0856\n",
      "Iteration: 2325; Percent complete: 58.1%; Average loss: 3.0673\n",
      "Iteration: 2326; Percent complete: 58.1%; Average loss: 3.3435\n",
      "Iteration: 2327; Percent complete: 58.2%; Average loss: 2.9903\n",
      "Iteration: 2328; Percent complete: 58.2%; Average loss: 3.0117\n",
      "Iteration: 2329; Percent complete: 58.2%; Average loss: 2.9235\n",
      "Iteration: 2330; Percent complete: 58.2%; Average loss: 2.8640\n",
      "Iteration: 2331; Percent complete: 58.3%; Average loss: 3.0030\n",
      "Iteration: 2332; Percent complete: 58.3%; Average loss: 3.0294\n",
      "Iteration: 2333; Percent complete: 58.3%; Average loss: 2.9110\n",
      "Iteration: 2334; Percent complete: 58.4%; Average loss: 3.1259\n",
      "Iteration: 2335; Percent complete: 58.4%; Average loss: 2.9505\n",
      "Iteration: 2336; Percent complete: 58.4%; Average loss: 3.0183\n",
      "Iteration: 2337; Percent complete: 58.4%; Average loss: 2.8304\n",
      "Iteration: 2338; Percent complete: 58.5%; Average loss: 2.8807\n",
      "Iteration: 2339; Percent complete: 58.5%; Average loss: 3.2286\n",
      "Iteration: 2340; Percent complete: 58.5%; Average loss: 3.1586\n",
      "Iteration: 2341; Percent complete: 58.5%; Average loss: 2.8803\n",
      "Iteration: 2342; Percent complete: 58.6%; Average loss: 2.8754\n",
      "Iteration: 2343; Percent complete: 58.6%; Average loss: 3.2058\n",
      "Iteration: 2344; Percent complete: 58.6%; Average loss: 3.0031\n",
      "Iteration: 2345; Percent complete: 58.6%; Average loss: 3.1690\n",
      "Iteration: 2346; Percent complete: 58.7%; Average loss: 3.3270\n",
      "Iteration: 2347; Percent complete: 58.7%; Average loss: 2.9478\n",
      "Iteration: 2348; Percent complete: 58.7%; Average loss: 3.1630\n",
      "Iteration: 2349; Percent complete: 58.7%; Average loss: 2.9801\n",
      "Iteration: 2350; Percent complete: 58.8%; Average loss: 3.1979\n",
      "Iteration: 2351; Percent complete: 58.8%; Average loss: 3.0051\n",
      "Iteration: 2352; Percent complete: 58.8%; Average loss: 3.0416\n",
      "Iteration: 2353; Percent complete: 58.8%; Average loss: 2.9327\n",
      "Iteration: 2354; Percent complete: 58.9%; Average loss: 3.1690\n",
      "Iteration: 2355; Percent complete: 58.9%; Average loss: 2.9761\n",
      "Iteration: 2356; Percent complete: 58.9%; Average loss: 2.9902\n",
      "Iteration: 2357; Percent complete: 58.9%; Average loss: 2.8185\n",
      "Iteration: 2358; Percent complete: 59.0%; Average loss: 3.1264\n",
      "Iteration: 2359; Percent complete: 59.0%; Average loss: 3.2167\n",
      "Iteration: 2360; Percent complete: 59.0%; Average loss: 3.0022\n",
      "Iteration: 2361; Percent complete: 59.0%; Average loss: 3.2044\n",
      "Iteration: 2362; Percent complete: 59.1%; Average loss: 2.9380\n",
      "Iteration: 2363; Percent complete: 59.1%; Average loss: 3.1538\n",
      "Iteration: 2364; Percent complete: 59.1%; Average loss: 3.0048\n",
      "Iteration: 2365; Percent complete: 59.1%; Average loss: 3.0695\n",
      "Iteration: 2366; Percent complete: 59.2%; Average loss: 2.9614\n",
      "Iteration: 2367; Percent complete: 59.2%; Average loss: 3.1102\n",
      "Iteration: 2368; Percent complete: 59.2%; Average loss: 2.9447\n",
      "Iteration: 2369; Percent complete: 59.2%; Average loss: 3.0691\n",
      "Iteration: 2370; Percent complete: 59.2%; Average loss: 3.1732\n",
      "Iteration: 2371; Percent complete: 59.3%; Average loss: 3.2164\n",
      "Iteration: 2372; Percent complete: 59.3%; Average loss: 2.9869\n",
      "Iteration: 2373; Percent complete: 59.3%; Average loss: 3.0778\n",
      "Iteration: 2374; Percent complete: 59.4%; Average loss: 3.0916\n",
      "Iteration: 2375; Percent complete: 59.4%; Average loss: 3.1359\n",
      "Iteration: 2376; Percent complete: 59.4%; Average loss: 3.2034\n",
      "Iteration: 2377; Percent complete: 59.4%; Average loss: 3.1660\n",
      "Iteration: 2378; Percent complete: 59.5%; Average loss: 2.9551\n",
      "Iteration: 2379; Percent complete: 59.5%; Average loss: 3.3111\n",
      "Iteration: 2380; Percent complete: 59.5%; Average loss: 2.9393\n",
      "Iteration: 2381; Percent complete: 59.5%; Average loss: 2.6801\n",
      "Iteration: 2382; Percent complete: 59.6%; Average loss: 3.0157\n",
      "Iteration: 2383; Percent complete: 59.6%; Average loss: 3.1034\n",
      "Iteration: 2384; Percent complete: 59.6%; Average loss: 2.8351\n",
      "Iteration: 2385; Percent complete: 59.6%; Average loss: 3.0670\n",
      "Iteration: 2386; Percent complete: 59.7%; Average loss: 3.1333\n",
      "Iteration: 2387; Percent complete: 59.7%; Average loss: 3.0150\n",
      "Iteration: 2388; Percent complete: 59.7%; Average loss: 3.0859\n",
      "Iteration: 2389; Percent complete: 59.7%; Average loss: 2.9433\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 2390; Percent complete: 59.8%; Average loss: 3.0626\n",
      "Iteration: 2391; Percent complete: 59.8%; Average loss: 3.0969\n",
      "Iteration: 2392; Percent complete: 59.8%; Average loss: 3.0734\n",
      "Iteration: 2393; Percent complete: 59.8%; Average loss: 2.9876\n",
      "Iteration: 2394; Percent complete: 59.9%; Average loss: 2.8286\n",
      "Iteration: 2395; Percent complete: 59.9%; Average loss: 3.0502\n",
      "Iteration: 2396; Percent complete: 59.9%; Average loss: 2.9817\n",
      "Iteration: 2397; Percent complete: 59.9%; Average loss: 3.1578\n",
      "Iteration: 2398; Percent complete: 60.0%; Average loss: 2.9945\n",
      "Iteration: 2399; Percent complete: 60.0%; Average loss: 2.9671\n",
      "Iteration: 2400; Percent complete: 60.0%; Average loss: 2.6864\n",
      "Iteration: 2401; Percent complete: 60.0%; Average loss: 2.9796\n",
      "Iteration: 2402; Percent complete: 60.1%; Average loss: 3.0052\n",
      "Iteration: 2403; Percent complete: 60.1%; Average loss: 3.0889\n",
      "Iteration: 2404; Percent complete: 60.1%; Average loss: 3.3127\n",
      "Iteration: 2405; Percent complete: 60.1%; Average loss: 3.1853\n",
      "Iteration: 2406; Percent complete: 60.2%; Average loss: 2.8812\n",
      "Iteration: 2407; Percent complete: 60.2%; Average loss: 3.2797\n",
      "Iteration: 2408; Percent complete: 60.2%; Average loss: 3.0290\n",
      "Iteration: 2409; Percent complete: 60.2%; Average loss: 3.1386\n",
      "Iteration: 2410; Percent complete: 60.2%; Average loss: 3.0310\n",
      "Iteration: 2411; Percent complete: 60.3%; Average loss: 2.9723\n",
      "Iteration: 2412; Percent complete: 60.3%; Average loss: 2.9825\n",
      "Iteration: 2413; Percent complete: 60.3%; Average loss: 2.8892\n",
      "Iteration: 2414; Percent complete: 60.4%; Average loss: 3.0504\n",
      "Iteration: 2415; Percent complete: 60.4%; Average loss: 3.3025\n",
      "Iteration: 2416; Percent complete: 60.4%; Average loss: 2.7254\n",
      "Iteration: 2417; Percent complete: 60.4%; Average loss: 2.9029\n",
      "Iteration: 2418; Percent complete: 60.5%; Average loss: 2.9344\n",
      "Iteration: 2419; Percent complete: 60.5%; Average loss: 3.1335\n",
      "Iteration: 2420; Percent complete: 60.5%; Average loss: 3.1643\n",
      "Iteration: 2421; Percent complete: 60.5%; Average loss: 2.8952\n",
      "Iteration: 2422; Percent complete: 60.6%; Average loss: 2.8760\n",
      "Iteration: 2423; Percent complete: 60.6%; Average loss: 3.1568\n",
      "Iteration: 2424; Percent complete: 60.6%; Average loss: 2.9974\n",
      "Iteration: 2425; Percent complete: 60.6%; Average loss: 3.0864\n",
      "Iteration: 2426; Percent complete: 60.7%; Average loss: 2.9193\n",
      "Iteration: 2427; Percent complete: 60.7%; Average loss: 3.2804\n",
      "Iteration: 2428; Percent complete: 60.7%; Average loss: 3.2427\n",
      "Iteration: 2429; Percent complete: 60.7%; Average loss: 2.8705\n",
      "Iteration: 2430; Percent complete: 60.8%; Average loss: 2.9594\n",
      "Iteration: 2431; Percent complete: 60.8%; Average loss: 3.2236\n",
      "Iteration: 2432; Percent complete: 60.8%; Average loss: 3.0461\n",
      "Iteration: 2433; Percent complete: 60.8%; Average loss: 3.2554\n",
      "Iteration: 2434; Percent complete: 60.9%; Average loss: 2.9410\n",
      "Iteration: 2435; Percent complete: 60.9%; Average loss: 2.9494\n",
      "Iteration: 2436; Percent complete: 60.9%; Average loss: 2.9624\n",
      "Iteration: 2437; Percent complete: 60.9%; Average loss: 3.0443\n",
      "Iteration: 2438; Percent complete: 61.0%; Average loss: 3.0534\n",
      "Iteration: 2439; Percent complete: 61.0%; Average loss: 3.2146\n",
      "Iteration: 2440; Percent complete: 61.0%; Average loss: 3.1495\n",
      "Iteration: 2441; Percent complete: 61.0%; Average loss: 3.0986\n",
      "Iteration: 2442; Percent complete: 61.1%; Average loss: 3.0917\n",
      "Iteration: 2443; Percent complete: 61.1%; Average loss: 2.9507\n",
      "Iteration: 2444; Percent complete: 61.1%; Average loss: 3.2330\n",
      "Iteration: 2445; Percent complete: 61.1%; Average loss: 3.0950\n",
      "Iteration: 2446; Percent complete: 61.2%; Average loss: 3.1106\n",
      "Iteration: 2447; Percent complete: 61.2%; Average loss: 3.0463\n",
      "Iteration: 2448; Percent complete: 61.2%; Average loss: 2.9945\n",
      "Iteration: 2449; Percent complete: 61.2%; Average loss: 3.1369\n",
      "Iteration: 2450; Percent complete: 61.3%; Average loss: 3.1254\n",
      "Iteration: 2451; Percent complete: 61.3%; Average loss: 2.9768\n",
      "Iteration: 2452; Percent complete: 61.3%; Average loss: 3.0512\n",
      "Iteration: 2453; Percent complete: 61.3%; Average loss: 3.0515\n",
      "Iteration: 2454; Percent complete: 61.4%; Average loss: 3.1771\n",
      "Iteration: 2455; Percent complete: 61.4%; Average loss: 2.9625\n",
      "Iteration: 2456; Percent complete: 61.4%; Average loss: 2.9778\n",
      "Iteration: 2457; Percent complete: 61.4%; Average loss: 3.1481\n",
      "Iteration: 2458; Percent complete: 61.5%; Average loss: 2.8651\n",
      "Iteration: 2459; Percent complete: 61.5%; Average loss: 2.9886\n",
      "Iteration: 2460; Percent complete: 61.5%; Average loss: 3.1062\n",
      "Iteration: 2461; Percent complete: 61.5%; Average loss: 2.9600\n",
      "Iteration: 2462; Percent complete: 61.6%; Average loss: 3.1641\n",
      "Iteration: 2463; Percent complete: 61.6%; Average loss: 3.1874\n",
      "Iteration: 2464; Percent complete: 61.6%; Average loss: 2.9698\n",
      "Iteration: 2465; Percent complete: 61.6%; Average loss: 2.7494\n",
      "Iteration: 2466; Percent complete: 61.7%; Average loss: 2.8443\n",
      "Iteration: 2467; Percent complete: 61.7%; Average loss: 2.9320\n",
      "Iteration: 2468; Percent complete: 61.7%; Average loss: 3.1086\n",
      "Iteration: 2469; Percent complete: 61.7%; Average loss: 2.9699\n",
      "Iteration: 2470; Percent complete: 61.8%; Average loss: 3.0190\n",
      "Iteration: 2471; Percent complete: 61.8%; Average loss: 2.9776\n",
      "Iteration: 2472; Percent complete: 61.8%; Average loss: 3.0649\n",
      "Iteration: 2473; Percent complete: 61.8%; Average loss: 2.7900\n",
      "Iteration: 2474; Percent complete: 61.9%; Average loss: 3.1830\n",
      "Iteration: 2475; Percent complete: 61.9%; Average loss: 2.7908\n",
      "Iteration: 2476; Percent complete: 61.9%; Average loss: 3.1511\n",
      "Iteration: 2477; Percent complete: 61.9%; Average loss: 3.3089\n",
      "Iteration: 2478; Percent complete: 62.0%; Average loss: 3.0123\n",
      "Iteration: 2479; Percent complete: 62.0%; Average loss: 3.0220\n",
      "Iteration: 2480; Percent complete: 62.0%; Average loss: 3.1906\n",
      "Iteration: 2481; Percent complete: 62.0%; Average loss: 3.0126\n",
      "Iteration: 2482; Percent complete: 62.1%; Average loss: 3.2683\n",
      "Iteration: 2483; Percent complete: 62.1%; Average loss: 3.0416\n",
      "Iteration: 2484; Percent complete: 62.1%; Average loss: 2.9008\n",
      "Iteration: 2485; Percent complete: 62.1%; Average loss: 3.0994\n",
      "Iteration: 2486; Percent complete: 62.2%; Average loss: 2.9316\n",
      "Iteration: 2487; Percent complete: 62.2%; Average loss: 2.8931\n",
      "Iteration: 2488; Percent complete: 62.2%; Average loss: 2.9950\n",
      "Iteration: 2489; Percent complete: 62.2%; Average loss: 3.0856\n",
      "Iteration: 2490; Percent complete: 62.3%; Average loss: 3.0274\n",
      "Iteration: 2491; Percent complete: 62.3%; Average loss: 2.8999\n",
      "Iteration: 2492; Percent complete: 62.3%; Average loss: 3.0418\n",
      "Iteration: 2493; Percent complete: 62.3%; Average loss: 3.1475\n",
      "Iteration: 2494; Percent complete: 62.4%; Average loss: 3.1245\n",
      "Iteration: 2495; Percent complete: 62.4%; Average loss: 2.8624\n",
      "Iteration: 2496; Percent complete: 62.4%; Average loss: 2.8736\n",
      "Iteration: 2497; Percent complete: 62.4%; Average loss: 2.9560\n",
      "Iteration: 2498; Percent complete: 62.5%; Average loss: 2.7321\n",
      "Iteration: 2499; Percent complete: 62.5%; Average loss: 2.9158\n",
      "Iteration: 2500; Percent complete: 62.5%; Average loss: 3.1724\n",
      "Iteration: 2501; Percent complete: 62.5%; Average loss: 2.9470\n",
      "Iteration: 2502; Percent complete: 62.5%; Average loss: 2.9576\n",
      "Iteration: 2503; Percent complete: 62.6%; Average loss: 3.1095\n",
      "Iteration: 2504; Percent complete: 62.6%; Average loss: 3.0237\n",
      "Iteration: 2505; Percent complete: 62.6%; Average loss: 2.8685\n",
      "Iteration: 2506; Percent complete: 62.6%; Average loss: 3.0072\n",
      "Iteration: 2507; Percent complete: 62.7%; Average loss: 3.1259\n",
      "Iteration: 2508; Percent complete: 62.7%; Average loss: 3.2598\n",
      "Iteration: 2509; Percent complete: 62.7%; Average loss: 3.0020\n",
      "Iteration: 2510; Percent complete: 62.7%; Average loss: 2.9152\n",
      "Iteration: 2511; Percent complete: 62.8%; Average loss: 3.1660\n",
      "Iteration: 2512; Percent complete: 62.8%; Average loss: 2.6985\n",
      "Iteration: 2513; Percent complete: 62.8%; Average loss: 2.8490\n",
      "Iteration: 2514; Percent complete: 62.8%; Average loss: 2.9520\n",
      "Iteration: 2515; Percent complete: 62.9%; Average loss: 3.0878\n",
      "Iteration: 2516; Percent complete: 62.9%; Average loss: 2.9505\n",
      "Iteration: 2517; Percent complete: 62.9%; Average loss: 2.9099\n",
      "Iteration: 2518; Percent complete: 62.9%; Average loss: 2.9143\n",
      "Iteration: 2519; Percent complete: 63.0%; Average loss: 3.0731\n",
      "Iteration: 2520; Percent complete: 63.0%; Average loss: 2.9024\n",
      "Iteration: 2521; Percent complete: 63.0%; Average loss: 3.0880\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 2522; Percent complete: 63.0%; Average loss: 2.7308\n",
      "Iteration: 2523; Percent complete: 63.1%; Average loss: 3.1867\n",
      "Iteration: 2524; Percent complete: 63.1%; Average loss: 2.9898\n",
      "Iteration: 2525; Percent complete: 63.1%; Average loss: 2.9608\n",
      "Iteration: 2526; Percent complete: 63.1%; Average loss: 3.1244\n",
      "Iteration: 2527; Percent complete: 63.2%; Average loss: 3.1245\n",
      "Iteration: 2528; Percent complete: 63.2%; Average loss: 3.1281\n",
      "Iteration: 2529; Percent complete: 63.2%; Average loss: 3.0125\n",
      "Iteration: 2530; Percent complete: 63.2%; Average loss: 2.8881\n",
      "Iteration: 2531; Percent complete: 63.3%; Average loss: 3.0854\n",
      "Iteration: 2532; Percent complete: 63.3%; Average loss: 2.9486\n",
      "Iteration: 2533; Percent complete: 63.3%; Average loss: 2.8379\n",
      "Iteration: 2534; Percent complete: 63.3%; Average loss: 2.9929\n",
      "Iteration: 2535; Percent complete: 63.4%; Average loss: 3.0200\n",
      "Iteration: 2536; Percent complete: 63.4%; Average loss: 2.9859\n",
      "Iteration: 2537; Percent complete: 63.4%; Average loss: 2.7345\n",
      "Iteration: 2538; Percent complete: 63.4%; Average loss: 2.9680\n",
      "Iteration: 2539; Percent complete: 63.5%; Average loss: 2.9749\n",
      "Iteration: 2540; Percent complete: 63.5%; Average loss: 2.8761\n",
      "Iteration: 2541; Percent complete: 63.5%; Average loss: 2.8824\n",
      "Iteration: 2542; Percent complete: 63.5%; Average loss: 2.9076\n",
      "Iteration: 2543; Percent complete: 63.6%; Average loss: 3.0491\n",
      "Iteration: 2544; Percent complete: 63.6%; Average loss: 3.3106\n",
      "Iteration: 2545; Percent complete: 63.6%; Average loss: 2.9394\n",
      "Iteration: 2546; Percent complete: 63.6%; Average loss: 2.9633\n",
      "Iteration: 2547; Percent complete: 63.7%; Average loss: 3.0459\n",
      "Iteration: 2548; Percent complete: 63.7%; Average loss: 2.9961\n",
      "Iteration: 2549; Percent complete: 63.7%; Average loss: 2.9700\n",
      "Iteration: 2550; Percent complete: 63.7%; Average loss: 3.1025\n",
      "Iteration: 2551; Percent complete: 63.8%; Average loss: 3.0242\n",
      "Iteration: 2552; Percent complete: 63.8%; Average loss: 3.0533\n",
      "Iteration: 2553; Percent complete: 63.8%; Average loss: 2.9281\n",
      "Iteration: 2554; Percent complete: 63.8%; Average loss: 3.0471\n",
      "Iteration: 2555; Percent complete: 63.9%; Average loss: 2.9789\n",
      "Iteration: 2556; Percent complete: 63.9%; Average loss: 2.7897\n",
      "Iteration: 2557; Percent complete: 63.9%; Average loss: 3.1036\n",
      "Iteration: 2558; Percent complete: 63.9%; Average loss: 2.8200\n",
      "Iteration: 2559; Percent complete: 64.0%; Average loss: 3.0559\n",
      "Iteration: 2560; Percent complete: 64.0%; Average loss: 2.9718\n",
      "Iteration: 2561; Percent complete: 64.0%; Average loss: 3.1403\n",
      "Iteration: 2562; Percent complete: 64.0%; Average loss: 2.9624\n",
      "Iteration: 2563; Percent complete: 64.1%; Average loss: 2.8884\n",
      "Iteration: 2564; Percent complete: 64.1%; Average loss: 3.3007\n",
      "Iteration: 2565; Percent complete: 64.1%; Average loss: 3.1069\n",
      "Iteration: 2566; Percent complete: 64.1%; Average loss: 2.9859\n",
      "Iteration: 2567; Percent complete: 64.2%; Average loss: 3.1432\n",
      "Iteration: 2568; Percent complete: 64.2%; Average loss: 3.1828\n",
      "Iteration: 2569; Percent complete: 64.2%; Average loss: 2.9126\n",
      "Iteration: 2570; Percent complete: 64.2%; Average loss: 3.0262\n",
      "Iteration: 2571; Percent complete: 64.3%; Average loss: 2.9023\n",
      "Iteration: 2572; Percent complete: 64.3%; Average loss: 2.9318\n",
      "Iteration: 2573; Percent complete: 64.3%; Average loss: 2.9686\n",
      "Iteration: 2574; Percent complete: 64.3%; Average loss: 2.9348\n",
      "Iteration: 2575; Percent complete: 64.4%; Average loss: 3.0733\n",
      "Iteration: 2576; Percent complete: 64.4%; Average loss: 2.9939\n",
      "Iteration: 2577; Percent complete: 64.4%; Average loss: 3.0257\n",
      "Iteration: 2578; Percent complete: 64.5%; Average loss: 3.1466\n",
      "Iteration: 2579; Percent complete: 64.5%; Average loss: 3.1966\n",
      "Iteration: 2580; Percent complete: 64.5%; Average loss: 3.1037\n",
      "Iteration: 2581; Percent complete: 64.5%; Average loss: 2.9904\n",
      "Iteration: 2582; Percent complete: 64.5%; Average loss: 2.9574\n",
      "Iteration: 2583; Percent complete: 64.6%; Average loss: 2.8912\n",
      "Iteration: 2584; Percent complete: 64.6%; Average loss: 2.7773\n",
      "Iteration: 2585; Percent complete: 64.6%; Average loss: 2.9782\n",
      "Iteration: 2586; Percent complete: 64.6%; Average loss: 3.0066\n",
      "Iteration: 2587; Percent complete: 64.7%; Average loss: 3.0194\n",
      "Iteration: 2588; Percent complete: 64.7%; Average loss: 2.9523\n",
      "Iteration: 2589; Percent complete: 64.7%; Average loss: 2.8846\n",
      "Iteration: 2590; Percent complete: 64.8%; Average loss: 3.0723\n",
      "Iteration: 2591; Percent complete: 64.8%; Average loss: 3.0050\n",
      "Iteration: 2592; Percent complete: 64.8%; Average loss: 3.2456\n",
      "Iteration: 2593; Percent complete: 64.8%; Average loss: 3.0879\n",
      "Iteration: 2594; Percent complete: 64.8%; Average loss: 2.9601\n",
      "Iteration: 2595; Percent complete: 64.9%; Average loss: 2.8132\n",
      "Iteration: 2596; Percent complete: 64.9%; Average loss: 3.0056\n",
      "Iteration: 2597; Percent complete: 64.9%; Average loss: 3.0245\n",
      "Iteration: 2598; Percent complete: 65.0%; Average loss: 3.0119\n",
      "Iteration: 2599; Percent complete: 65.0%; Average loss: 3.1708\n",
      "Iteration: 2600; Percent complete: 65.0%; Average loss: 2.7808\n",
      "Iteration: 2601; Percent complete: 65.0%; Average loss: 3.0843\n",
      "Iteration: 2602; Percent complete: 65.0%; Average loss: 3.2068\n",
      "Iteration: 2603; Percent complete: 65.1%; Average loss: 3.2679\n",
      "Iteration: 2604; Percent complete: 65.1%; Average loss: 2.8773\n",
      "Iteration: 2605; Percent complete: 65.1%; Average loss: 2.9573\n",
      "Iteration: 2606; Percent complete: 65.1%; Average loss: 2.8456\n",
      "Iteration: 2607; Percent complete: 65.2%; Average loss: 2.9147\n",
      "Iteration: 2608; Percent complete: 65.2%; Average loss: 2.9938\n",
      "Iteration: 2609; Percent complete: 65.2%; Average loss: 3.0747\n",
      "Iteration: 2610; Percent complete: 65.2%; Average loss: 2.8821\n",
      "Iteration: 2611; Percent complete: 65.3%; Average loss: 2.9684\n",
      "Iteration: 2612; Percent complete: 65.3%; Average loss: 3.0991\n",
      "Iteration: 2613; Percent complete: 65.3%; Average loss: 2.8061\n",
      "Iteration: 2614; Percent complete: 65.3%; Average loss: 3.2760\n",
      "Iteration: 2615; Percent complete: 65.4%; Average loss: 2.8522\n",
      "Iteration: 2616; Percent complete: 65.4%; Average loss: 2.9026\n",
      "Iteration: 2617; Percent complete: 65.4%; Average loss: 3.0830\n",
      "Iteration: 2618; Percent complete: 65.5%; Average loss: 3.0577\n",
      "Iteration: 2619; Percent complete: 65.5%; Average loss: 2.9671\n",
      "Iteration: 2620; Percent complete: 65.5%; Average loss: 3.1186\n",
      "Iteration: 2621; Percent complete: 65.5%; Average loss: 2.9852\n",
      "Iteration: 2622; Percent complete: 65.5%; Average loss: 2.8488\n",
      "Iteration: 2623; Percent complete: 65.6%; Average loss: 2.9918\n",
      "Iteration: 2624; Percent complete: 65.6%; Average loss: 2.9980\n",
      "Iteration: 2625; Percent complete: 65.6%; Average loss: 2.8820\n",
      "Iteration: 2626; Percent complete: 65.6%; Average loss: 3.1107\n",
      "Iteration: 2627; Percent complete: 65.7%; Average loss: 2.8101\n",
      "Iteration: 2628; Percent complete: 65.7%; Average loss: 3.0807\n",
      "Iteration: 2629; Percent complete: 65.7%; Average loss: 3.0557\n",
      "Iteration: 2630; Percent complete: 65.8%; Average loss: 2.9541\n",
      "Iteration: 2631; Percent complete: 65.8%; Average loss: 2.7269\n",
      "Iteration: 2632; Percent complete: 65.8%; Average loss: 2.8745\n",
      "Iteration: 2633; Percent complete: 65.8%; Average loss: 2.9340\n",
      "Iteration: 2634; Percent complete: 65.8%; Average loss: 3.0151\n",
      "Iteration: 2635; Percent complete: 65.9%; Average loss: 2.8560\n",
      "Iteration: 2636; Percent complete: 65.9%; Average loss: 3.1394\n",
      "Iteration: 2637; Percent complete: 65.9%; Average loss: 3.0408\n",
      "Iteration: 2638; Percent complete: 66.0%; Average loss: 2.9998\n",
      "Iteration: 2639; Percent complete: 66.0%; Average loss: 2.9451\n",
      "Iteration: 2640; Percent complete: 66.0%; Average loss: 2.9563\n",
      "Iteration: 2641; Percent complete: 66.0%; Average loss: 3.0317\n",
      "Iteration: 2642; Percent complete: 66.0%; Average loss: 2.9768\n",
      "Iteration: 2643; Percent complete: 66.1%; Average loss: 2.9956\n",
      "Iteration: 2644; Percent complete: 66.1%; Average loss: 3.1274\n",
      "Iteration: 2645; Percent complete: 66.1%; Average loss: 3.0041\n",
      "Iteration: 2646; Percent complete: 66.1%; Average loss: 3.0382\n",
      "Iteration: 2647; Percent complete: 66.2%; Average loss: 2.8058\n",
      "Iteration: 2648; Percent complete: 66.2%; Average loss: 2.9742\n",
      "Iteration: 2649; Percent complete: 66.2%; Average loss: 2.8955\n",
      "Iteration: 2650; Percent complete: 66.2%; Average loss: 2.8526\n",
      "Iteration: 2651; Percent complete: 66.3%; Average loss: 3.2619\n",
      "Iteration: 2652; Percent complete: 66.3%; Average loss: 3.0911\n",
      "Iteration: 2653; Percent complete: 66.3%; Average loss: 2.9051\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 2654; Percent complete: 66.3%; Average loss: 2.8410\n",
      "Iteration: 2655; Percent complete: 66.4%; Average loss: 2.9438\n",
      "Iteration: 2656; Percent complete: 66.4%; Average loss: 3.0637\n",
      "Iteration: 2657; Percent complete: 66.4%; Average loss: 2.8763\n",
      "Iteration: 2658; Percent complete: 66.5%; Average loss: 2.8724\n",
      "Iteration: 2659; Percent complete: 66.5%; Average loss: 3.0625\n",
      "Iteration: 2660; Percent complete: 66.5%; Average loss: 2.9473\n",
      "Iteration: 2661; Percent complete: 66.5%; Average loss: 3.0308\n",
      "Iteration: 2662; Percent complete: 66.5%; Average loss: 2.9495\n",
      "Iteration: 2663; Percent complete: 66.6%; Average loss: 2.9588\n",
      "Iteration: 2664; Percent complete: 66.6%; Average loss: 3.0128\n",
      "Iteration: 2665; Percent complete: 66.6%; Average loss: 3.0249\n",
      "Iteration: 2666; Percent complete: 66.6%; Average loss: 2.9060\n",
      "Iteration: 2667; Percent complete: 66.7%; Average loss: 2.6305\n",
      "Iteration: 2668; Percent complete: 66.7%; Average loss: 2.7773\n",
      "Iteration: 2669; Percent complete: 66.7%; Average loss: 2.8305\n",
      "Iteration: 2670; Percent complete: 66.8%; Average loss: 3.0514\n",
      "Iteration: 2671; Percent complete: 66.8%; Average loss: 2.8023\n",
      "Iteration: 2672; Percent complete: 66.8%; Average loss: 3.0199\n",
      "Iteration: 2673; Percent complete: 66.8%; Average loss: 3.1784\n",
      "Iteration: 2674; Percent complete: 66.8%; Average loss: 2.9211\n",
      "Iteration: 2675; Percent complete: 66.9%; Average loss: 2.9509\n",
      "Iteration: 2676; Percent complete: 66.9%; Average loss: 3.0902\n",
      "Iteration: 2677; Percent complete: 66.9%; Average loss: 3.0224\n",
      "Iteration: 2678; Percent complete: 67.0%; Average loss: 2.9323\n",
      "Iteration: 2679; Percent complete: 67.0%; Average loss: 2.6615\n",
      "Iteration: 2680; Percent complete: 67.0%; Average loss: 2.9335\n",
      "Iteration: 2681; Percent complete: 67.0%; Average loss: 2.8713\n",
      "Iteration: 2682; Percent complete: 67.0%; Average loss: 2.8505\n",
      "Iteration: 2683; Percent complete: 67.1%; Average loss: 2.9898\n",
      "Iteration: 2684; Percent complete: 67.1%; Average loss: 2.8692\n",
      "Iteration: 2685; Percent complete: 67.1%; Average loss: 2.9909\n",
      "Iteration: 2686; Percent complete: 67.2%; Average loss: 3.0422\n",
      "Iteration: 2687; Percent complete: 67.2%; Average loss: 2.9810\n",
      "Iteration: 2688; Percent complete: 67.2%; Average loss: 2.9953\n",
      "Iteration: 2689; Percent complete: 67.2%; Average loss: 2.8406\n",
      "Iteration: 2690; Percent complete: 67.2%; Average loss: 3.0189\n",
      "Iteration: 2691; Percent complete: 67.3%; Average loss: 3.1198\n",
      "Iteration: 2692; Percent complete: 67.3%; Average loss: 2.7882\n",
      "Iteration: 2693; Percent complete: 67.3%; Average loss: 2.9069\n",
      "Iteration: 2694; Percent complete: 67.3%; Average loss: 3.0435\n",
      "Iteration: 2695; Percent complete: 67.4%; Average loss: 2.7258\n",
      "Iteration: 2696; Percent complete: 67.4%; Average loss: 3.0959\n",
      "Iteration: 2697; Percent complete: 67.4%; Average loss: 2.8690\n",
      "Iteration: 2698; Percent complete: 67.5%; Average loss: 2.8659\n",
      "Iteration: 2699; Percent complete: 67.5%; Average loss: 2.7215\n",
      "Iteration: 2700; Percent complete: 67.5%; Average loss: 2.8985\n",
      "Iteration: 2701; Percent complete: 67.5%; Average loss: 2.9145\n",
      "Iteration: 2702; Percent complete: 67.5%; Average loss: 2.7051\n",
      "Iteration: 2703; Percent complete: 67.6%; Average loss: 2.5933\n",
      "Iteration: 2704; Percent complete: 67.6%; Average loss: 3.2500\n",
      "Iteration: 2705; Percent complete: 67.6%; Average loss: 3.0007\n",
      "Iteration: 2706; Percent complete: 67.7%; Average loss: 2.9533\n",
      "Iteration: 2707; Percent complete: 67.7%; Average loss: 2.8811\n",
      "Iteration: 2708; Percent complete: 67.7%; Average loss: 3.1333\n",
      "Iteration: 2709; Percent complete: 67.7%; Average loss: 2.9683\n",
      "Iteration: 2710; Percent complete: 67.8%; Average loss: 2.7544\n",
      "Iteration: 2711; Percent complete: 67.8%; Average loss: 2.9069\n",
      "Iteration: 2712; Percent complete: 67.8%; Average loss: 2.9644\n",
      "Iteration: 2713; Percent complete: 67.8%; Average loss: 3.0535\n",
      "Iteration: 2714; Percent complete: 67.8%; Average loss: 2.8966\n",
      "Iteration: 2715; Percent complete: 67.9%; Average loss: 2.9257\n",
      "Iteration: 2716; Percent complete: 67.9%; Average loss: 2.7974\n",
      "Iteration: 2717; Percent complete: 67.9%; Average loss: 3.0255\n",
      "Iteration: 2718; Percent complete: 68.0%; Average loss: 2.9116\n",
      "Iteration: 2719; Percent complete: 68.0%; Average loss: 2.7029\n",
      "Iteration: 2720; Percent complete: 68.0%; Average loss: 2.8603\n",
      "Iteration: 2721; Percent complete: 68.0%; Average loss: 2.8734\n",
      "Iteration: 2722; Percent complete: 68.0%; Average loss: 2.8892\n",
      "Iteration: 2723; Percent complete: 68.1%; Average loss: 2.8730\n",
      "Iteration: 2724; Percent complete: 68.1%; Average loss: 3.1861\n",
      "Iteration: 2725; Percent complete: 68.1%; Average loss: 2.8336\n",
      "Iteration: 2726; Percent complete: 68.2%; Average loss: 3.0667\n",
      "Iteration: 2727; Percent complete: 68.2%; Average loss: 2.9285\n",
      "Iteration: 2728; Percent complete: 68.2%; Average loss: 2.8729\n",
      "Iteration: 2729; Percent complete: 68.2%; Average loss: 2.9087\n",
      "Iteration: 2730; Percent complete: 68.2%; Average loss: 3.0422\n",
      "Iteration: 2731; Percent complete: 68.3%; Average loss: 3.0262\n",
      "Iteration: 2732; Percent complete: 68.3%; Average loss: 2.9280\n",
      "Iteration: 2733; Percent complete: 68.3%; Average loss: 3.0139\n",
      "Iteration: 2734; Percent complete: 68.3%; Average loss: 2.8348\n",
      "Iteration: 2735; Percent complete: 68.4%; Average loss: 3.0160\n",
      "Iteration: 2736; Percent complete: 68.4%; Average loss: 2.8990\n",
      "Iteration: 2737; Percent complete: 68.4%; Average loss: 3.1699\n",
      "Iteration: 2738; Percent complete: 68.5%; Average loss: 2.9875\n",
      "Iteration: 2739; Percent complete: 68.5%; Average loss: 3.0216\n",
      "Iteration: 2740; Percent complete: 68.5%; Average loss: 2.7590\n",
      "Iteration: 2741; Percent complete: 68.5%; Average loss: 3.1058\n",
      "Iteration: 2742; Percent complete: 68.5%; Average loss: 2.8371\n",
      "Iteration: 2743; Percent complete: 68.6%; Average loss: 2.7530\n",
      "Iteration: 2744; Percent complete: 68.6%; Average loss: 2.8020\n",
      "Iteration: 2745; Percent complete: 68.6%; Average loss: 3.2032\n",
      "Iteration: 2746; Percent complete: 68.7%; Average loss: 2.8343\n",
      "Iteration: 2747; Percent complete: 68.7%; Average loss: 2.7955\n",
      "Iteration: 2748; Percent complete: 68.7%; Average loss: 2.9574\n",
      "Iteration: 2749; Percent complete: 68.7%; Average loss: 2.9955\n",
      "Iteration: 2750; Percent complete: 68.8%; Average loss: 3.0234\n",
      "Iteration: 2751; Percent complete: 68.8%; Average loss: 2.8452\n",
      "Iteration: 2752; Percent complete: 68.8%; Average loss: 3.0757\n",
      "Iteration: 2753; Percent complete: 68.8%; Average loss: 3.1943\n",
      "Iteration: 2754; Percent complete: 68.8%; Average loss: 2.8040\n",
      "Iteration: 2755; Percent complete: 68.9%; Average loss: 3.0489\n",
      "Iteration: 2756; Percent complete: 68.9%; Average loss: 2.7479\n",
      "Iteration: 2757; Percent complete: 68.9%; Average loss: 2.8838\n",
      "Iteration: 2758; Percent complete: 69.0%; Average loss: 2.9765\n",
      "Iteration: 2759; Percent complete: 69.0%; Average loss: 2.9766\n",
      "Iteration: 2760; Percent complete: 69.0%; Average loss: 2.9854\n",
      "Iteration: 2761; Percent complete: 69.0%; Average loss: 2.9577\n",
      "Iteration: 2762; Percent complete: 69.0%; Average loss: 2.8985\n",
      "Iteration: 2763; Percent complete: 69.1%; Average loss: 3.0269\n",
      "Iteration: 2764; Percent complete: 69.1%; Average loss: 2.8533\n",
      "Iteration: 2765; Percent complete: 69.1%; Average loss: 3.0559\n",
      "Iteration: 2766; Percent complete: 69.2%; Average loss: 2.7955\n",
      "Iteration: 2767; Percent complete: 69.2%; Average loss: 2.9220\n",
      "Iteration: 2768; Percent complete: 69.2%; Average loss: 2.9736\n",
      "Iteration: 2769; Percent complete: 69.2%; Average loss: 3.2023\n",
      "Iteration: 2770; Percent complete: 69.2%; Average loss: 2.6710\n",
      "Iteration: 2771; Percent complete: 69.3%; Average loss: 3.0144\n",
      "Iteration: 2772; Percent complete: 69.3%; Average loss: 2.9239\n",
      "Iteration: 2773; Percent complete: 69.3%; Average loss: 2.9138\n",
      "Iteration: 2774; Percent complete: 69.3%; Average loss: 2.9815\n",
      "Iteration: 2775; Percent complete: 69.4%; Average loss: 3.1613\n",
      "Iteration: 2776; Percent complete: 69.4%; Average loss: 2.9068\n",
      "Iteration: 2777; Percent complete: 69.4%; Average loss: 2.9792\n",
      "Iteration: 2778; Percent complete: 69.5%; Average loss: 2.8331\n",
      "Iteration: 2779; Percent complete: 69.5%; Average loss: 2.9340\n",
      "Iteration: 2780; Percent complete: 69.5%; Average loss: 3.1171\n",
      "Iteration: 2781; Percent complete: 69.5%; Average loss: 2.9822\n",
      "Iteration: 2782; Percent complete: 69.5%; Average loss: 2.8531\n",
      "Iteration: 2783; Percent complete: 69.6%; Average loss: 3.1442\n",
      "Iteration: 2784; Percent complete: 69.6%; Average loss: 2.8236\n",
      "Iteration: 2785; Percent complete: 69.6%; Average loss: 3.0049\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 2786; Percent complete: 69.7%; Average loss: 3.0115\n",
      "Iteration: 2787; Percent complete: 69.7%; Average loss: 3.1998\n",
      "Iteration: 2788; Percent complete: 69.7%; Average loss: 2.7926\n",
      "Iteration: 2789; Percent complete: 69.7%; Average loss: 2.6741\n",
      "Iteration: 2790; Percent complete: 69.8%; Average loss: 2.6764\n",
      "Iteration: 2791; Percent complete: 69.8%; Average loss: 2.8481\n",
      "Iteration: 2792; Percent complete: 69.8%; Average loss: 2.8781\n",
      "Iteration: 2793; Percent complete: 69.8%; Average loss: 2.8864\n",
      "Iteration: 2794; Percent complete: 69.8%; Average loss: 3.0055\n",
      "Iteration: 2795; Percent complete: 69.9%; Average loss: 2.9625\n",
      "Iteration: 2796; Percent complete: 69.9%; Average loss: 2.7661\n",
      "Iteration: 2797; Percent complete: 69.9%; Average loss: 2.6037\n",
      "Iteration: 2798; Percent complete: 70.0%; Average loss: 2.8639\n",
      "Iteration: 2799; Percent complete: 70.0%; Average loss: 2.7378\n",
      "Iteration: 2800; Percent complete: 70.0%; Average loss: 2.7962\n",
      "Iteration: 2801; Percent complete: 70.0%; Average loss: 2.7118\n",
      "Iteration: 2802; Percent complete: 70.0%; Average loss: 2.9153\n",
      "Iteration: 2803; Percent complete: 70.1%; Average loss: 2.5842\n",
      "Iteration: 2804; Percent complete: 70.1%; Average loss: 2.7697\n",
      "Iteration: 2805; Percent complete: 70.1%; Average loss: 2.9843\n",
      "Iteration: 2806; Percent complete: 70.2%; Average loss: 2.9608\n",
      "Iteration: 2807; Percent complete: 70.2%; Average loss: 2.7528\n",
      "Iteration: 2808; Percent complete: 70.2%; Average loss: 3.0092\n",
      "Iteration: 2809; Percent complete: 70.2%; Average loss: 2.8040\n",
      "Iteration: 2810; Percent complete: 70.2%; Average loss: 2.9703\n",
      "Iteration: 2811; Percent complete: 70.3%; Average loss: 2.9076\n",
      "Iteration: 2812; Percent complete: 70.3%; Average loss: 2.9995\n",
      "Iteration: 2813; Percent complete: 70.3%; Average loss: 2.8346\n",
      "Iteration: 2814; Percent complete: 70.3%; Average loss: 2.8070\n",
      "Iteration: 2815; Percent complete: 70.4%; Average loss: 3.0690\n",
      "Iteration: 2816; Percent complete: 70.4%; Average loss: 2.9908\n",
      "Iteration: 2817; Percent complete: 70.4%; Average loss: 2.8444\n",
      "Iteration: 2818; Percent complete: 70.5%; Average loss: 2.7587\n",
      "Iteration: 2819; Percent complete: 70.5%; Average loss: 3.2172\n",
      "Iteration: 2820; Percent complete: 70.5%; Average loss: 3.0035\n",
      "Iteration: 2821; Percent complete: 70.5%; Average loss: 2.8479\n",
      "Iteration: 2822; Percent complete: 70.5%; Average loss: 2.9773\n",
      "Iteration: 2823; Percent complete: 70.6%; Average loss: 2.8607\n",
      "Iteration: 2824; Percent complete: 70.6%; Average loss: 2.8737\n",
      "Iteration: 2825; Percent complete: 70.6%; Average loss: 2.9977\n",
      "Iteration: 2826; Percent complete: 70.7%; Average loss: 2.6986\n",
      "Iteration: 2827; Percent complete: 70.7%; Average loss: 3.0103\n",
      "Iteration: 2828; Percent complete: 70.7%; Average loss: 2.8519\n",
      "Iteration: 2829; Percent complete: 70.7%; Average loss: 2.6420\n",
      "Iteration: 2830; Percent complete: 70.8%; Average loss: 2.8118\n",
      "Iteration: 2831; Percent complete: 70.8%; Average loss: 2.8278\n",
      "Iteration: 2832; Percent complete: 70.8%; Average loss: 2.8548\n",
      "Iteration: 2833; Percent complete: 70.8%; Average loss: 2.8712\n",
      "Iteration: 2834; Percent complete: 70.9%; Average loss: 2.7807\n",
      "Iteration: 2835; Percent complete: 70.9%; Average loss: 2.8410\n",
      "Iteration: 2836; Percent complete: 70.9%; Average loss: 2.8916\n",
      "Iteration: 2837; Percent complete: 70.9%; Average loss: 2.8539\n",
      "Iteration: 2838; Percent complete: 71.0%; Average loss: 2.9642\n",
      "Iteration: 2839; Percent complete: 71.0%; Average loss: 2.9656\n",
      "Iteration: 2840; Percent complete: 71.0%; Average loss: 2.8021\n",
      "Iteration: 2841; Percent complete: 71.0%; Average loss: 2.9001\n",
      "Iteration: 2842; Percent complete: 71.0%; Average loss: 3.0586\n",
      "Iteration: 2843; Percent complete: 71.1%; Average loss: 2.8147\n",
      "Iteration: 2844; Percent complete: 71.1%; Average loss: 2.9364\n",
      "Iteration: 2845; Percent complete: 71.1%; Average loss: 3.0973\n",
      "Iteration: 2846; Percent complete: 71.2%; Average loss: 2.7966\n",
      "Iteration: 2847; Percent complete: 71.2%; Average loss: 2.9563\n",
      "Iteration: 2848; Percent complete: 71.2%; Average loss: 3.1706\n",
      "Iteration: 2849; Percent complete: 71.2%; Average loss: 2.9236\n",
      "Iteration: 2850; Percent complete: 71.2%; Average loss: 3.1361\n",
      "Iteration: 2851; Percent complete: 71.3%; Average loss: 3.2743\n",
      "Iteration: 2852; Percent complete: 71.3%; Average loss: 2.7810\n",
      "Iteration: 2853; Percent complete: 71.3%; Average loss: 2.8434\n",
      "Iteration: 2854; Percent complete: 71.4%; Average loss: 2.8952\n",
      "Iteration: 2855; Percent complete: 71.4%; Average loss: 2.8812\n",
      "Iteration: 2856; Percent complete: 71.4%; Average loss: 2.9426\n",
      "Iteration: 2857; Percent complete: 71.4%; Average loss: 3.1116\n",
      "Iteration: 2858; Percent complete: 71.5%; Average loss: 3.1391\n",
      "Iteration: 2859; Percent complete: 71.5%; Average loss: 3.0402\n",
      "Iteration: 2860; Percent complete: 71.5%; Average loss: 2.9190\n",
      "Iteration: 2861; Percent complete: 71.5%; Average loss: 2.9989\n",
      "Iteration: 2862; Percent complete: 71.5%; Average loss: 2.8217\n",
      "Iteration: 2863; Percent complete: 71.6%; Average loss: 3.0705\n",
      "Iteration: 2864; Percent complete: 71.6%; Average loss: 2.8408\n",
      "Iteration: 2865; Percent complete: 71.6%; Average loss: 3.0771\n",
      "Iteration: 2866; Percent complete: 71.7%; Average loss: 2.9186\n",
      "Iteration: 2867; Percent complete: 71.7%; Average loss: 2.9114\n",
      "Iteration: 2868; Percent complete: 71.7%; Average loss: 2.8982\n",
      "Iteration: 2869; Percent complete: 71.7%; Average loss: 2.9985\n",
      "Iteration: 2870; Percent complete: 71.8%; Average loss: 2.8411\n",
      "Iteration: 2871; Percent complete: 71.8%; Average loss: 2.7871\n",
      "Iteration: 2872; Percent complete: 71.8%; Average loss: 2.7826\n",
      "Iteration: 2873; Percent complete: 71.8%; Average loss: 3.1289\n",
      "Iteration: 2874; Percent complete: 71.9%; Average loss: 2.9830\n",
      "Iteration: 2875; Percent complete: 71.9%; Average loss: 2.8152\n",
      "Iteration: 2876; Percent complete: 71.9%; Average loss: 2.7313\n",
      "Iteration: 2877; Percent complete: 71.9%; Average loss: 3.2696\n",
      "Iteration: 2878; Percent complete: 72.0%; Average loss: 2.7957\n",
      "Iteration: 2879; Percent complete: 72.0%; Average loss: 2.9881\n",
      "Iteration: 2880; Percent complete: 72.0%; Average loss: 2.8914\n",
      "Iteration: 2881; Percent complete: 72.0%; Average loss: 2.9023\n",
      "Iteration: 2882; Percent complete: 72.0%; Average loss: 2.9417\n",
      "Iteration: 2883; Percent complete: 72.1%; Average loss: 2.9101\n",
      "Iteration: 2884; Percent complete: 72.1%; Average loss: 3.2088\n",
      "Iteration: 2885; Percent complete: 72.1%; Average loss: 2.9078\n",
      "Iteration: 2886; Percent complete: 72.2%; Average loss: 2.7929\n",
      "Iteration: 2887; Percent complete: 72.2%; Average loss: 3.0380\n",
      "Iteration: 2888; Percent complete: 72.2%; Average loss: 2.5799\n",
      "Iteration: 2889; Percent complete: 72.2%; Average loss: 2.9004\n",
      "Iteration: 2890; Percent complete: 72.2%; Average loss: 3.0564\n",
      "Iteration: 2891; Percent complete: 72.3%; Average loss: 3.0801\n",
      "Iteration: 2892; Percent complete: 72.3%; Average loss: 2.8287\n",
      "Iteration: 2893; Percent complete: 72.3%; Average loss: 2.8522\n",
      "Iteration: 2894; Percent complete: 72.4%; Average loss: 2.8061\n",
      "Iteration: 2895; Percent complete: 72.4%; Average loss: 2.8948\n",
      "Iteration: 2896; Percent complete: 72.4%; Average loss: 2.8293\n",
      "Iteration: 2897; Percent complete: 72.4%; Average loss: 2.8990\n",
      "Iteration: 2898; Percent complete: 72.5%; Average loss: 2.6860\n",
      "Iteration: 2899; Percent complete: 72.5%; Average loss: 2.9695\n",
      "Iteration: 2900; Percent complete: 72.5%; Average loss: 2.7970\n",
      "Iteration: 2901; Percent complete: 72.5%; Average loss: 2.7763\n",
      "Iteration: 2902; Percent complete: 72.5%; Average loss: 2.7691\n",
      "Iteration: 2903; Percent complete: 72.6%; Average loss: 2.8798\n",
      "Iteration: 2904; Percent complete: 72.6%; Average loss: 2.8854\n",
      "Iteration: 2905; Percent complete: 72.6%; Average loss: 2.7862\n",
      "Iteration: 2906; Percent complete: 72.7%; Average loss: 2.7314\n",
      "Iteration: 2907; Percent complete: 72.7%; Average loss: 2.8176\n",
      "Iteration: 2908; Percent complete: 72.7%; Average loss: 2.9864\n",
      "Iteration: 2909; Percent complete: 72.7%; Average loss: 2.5533\n",
      "Iteration: 2910; Percent complete: 72.8%; Average loss: 3.0446\n",
      "Iteration: 2911; Percent complete: 72.8%; Average loss: 2.9752\n",
      "Iteration: 2912; Percent complete: 72.8%; Average loss: 2.8990\n",
      "Iteration: 2913; Percent complete: 72.8%; Average loss: 2.9061\n",
      "Iteration: 2914; Percent complete: 72.9%; Average loss: 2.8481\n",
      "Iteration: 2915; Percent complete: 72.9%; Average loss: 2.8549\n",
      "Iteration: 2916; Percent complete: 72.9%; Average loss: 2.8143\n",
      "Iteration: 2917; Percent complete: 72.9%; Average loss: 2.9106\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 2918; Percent complete: 73.0%; Average loss: 2.9083\n",
      "Iteration: 2919; Percent complete: 73.0%; Average loss: 2.8574\n",
      "Iteration: 2920; Percent complete: 73.0%; Average loss: 2.9979\n",
      "Iteration: 2921; Percent complete: 73.0%; Average loss: 2.9449\n",
      "Iteration: 2922; Percent complete: 73.0%; Average loss: 2.8473\n",
      "Iteration: 2923; Percent complete: 73.1%; Average loss: 3.0324\n",
      "Iteration: 2924; Percent complete: 73.1%; Average loss: 2.9126\n",
      "Iteration: 2925; Percent complete: 73.1%; Average loss: 2.8594\n",
      "Iteration: 2926; Percent complete: 73.2%; Average loss: 2.6337\n",
      "Iteration: 2927; Percent complete: 73.2%; Average loss: 2.9330\n",
      "Iteration: 2928; Percent complete: 73.2%; Average loss: 2.6937\n",
      "Iteration: 2929; Percent complete: 73.2%; Average loss: 3.1103\n",
      "Iteration: 2930; Percent complete: 73.2%; Average loss: 2.8463\n",
      "Iteration: 2931; Percent complete: 73.3%; Average loss: 3.0689\n",
      "Iteration: 2932; Percent complete: 73.3%; Average loss: 2.8107\n",
      "Iteration: 2933; Percent complete: 73.3%; Average loss: 2.7824\n",
      "Iteration: 2934; Percent complete: 73.4%; Average loss: 2.7867\n",
      "Iteration: 2935; Percent complete: 73.4%; Average loss: 3.2043\n",
      "Iteration: 2936; Percent complete: 73.4%; Average loss: 2.7552\n",
      "Iteration: 2937; Percent complete: 73.4%; Average loss: 2.9903\n",
      "Iteration: 2938; Percent complete: 73.5%; Average loss: 2.7408\n",
      "Iteration: 2939; Percent complete: 73.5%; Average loss: 3.0708\n",
      "Iteration: 2940; Percent complete: 73.5%; Average loss: 2.8864\n",
      "Iteration: 2941; Percent complete: 73.5%; Average loss: 2.8782\n",
      "Iteration: 2942; Percent complete: 73.6%; Average loss: 2.8676\n",
      "Iteration: 2943; Percent complete: 73.6%; Average loss: 2.9078\n",
      "Iteration: 2944; Percent complete: 73.6%; Average loss: 2.9522\n",
      "Iteration: 2945; Percent complete: 73.6%; Average loss: 2.8677\n",
      "Iteration: 2946; Percent complete: 73.7%; Average loss: 2.7889\n",
      "Iteration: 2947; Percent complete: 73.7%; Average loss: 2.9120\n",
      "Iteration: 2948; Percent complete: 73.7%; Average loss: 2.8595\n",
      "Iteration: 2949; Percent complete: 73.7%; Average loss: 2.6278\n",
      "Iteration: 2950; Percent complete: 73.8%; Average loss: 2.8928\n",
      "Iteration: 2951; Percent complete: 73.8%; Average loss: 2.8798\n",
      "Iteration: 2952; Percent complete: 73.8%; Average loss: 2.9602\n",
      "Iteration: 2953; Percent complete: 73.8%; Average loss: 2.9309\n",
      "Iteration: 2954; Percent complete: 73.9%; Average loss: 2.8005\n",
      "Iteration: 2955; Percent complete: 73.9%; Average loss: 2.7576\n",
      "Iteration: 2956; Percent complete: 73.9%; Average loss: 3.0650\n",
      "Iteration: 2957; Percent complete: 73.9%; Average loss: 3.0190\n",
      "Iteration: 2958; Percent complete: 74.0%; Average loss: 2.8310\n",
      "Iteration: 2959; Percent complete: 74.0%; Average loss: 2.9138\n",
      "Iteration: 2960; Percent complete: 74.0%; Average loss: 2.6403\n",
      "Iteration: 2961; Percent complete: 74.0%; Average loss: 3.0276\n",
      "Iteration: 2962; Percent complete: 74.1%; Average loss: 2.9316\n",
      "Iteration: 2963; Percent complete: 74.1%; Average loss: 2.7960\n",
      "Iteration: 2964; Percent complete: 74.1%; Average loss: 2.9338\n",
      "Iteration: 2965; Percent complete: 74.1%; Average loss: 2.8651\n",
      "Iteration: 2966; Percent complete: 74.2%; Average loss: 2.7739\n",
      "Iteration: 2967; Percent complete: 74.2%; Average loss: 3.1187\n",
      "Iteration: 2968; Percent complete: 74.2%; Average loss: 3.2251\n",
      "Iteration: 2969; Percent complete: 74.2%; Average loss: 2.9837\n",
      "Iteration: 2970; Percent complete: 74.2%; Average loss: 2.8958\n",
      "Iteration: 2971; Percent complete: 74.3%; Average loss: 2.6386\n",
      "Iteration: 2972; Percent complete: 74.3%; Average loss: 2.9870\n",
      "Iteration: 2973; Percent complete: 74.3%; Average loss: 2.8193\n",
      "Iteration: 2974; Percent complete: 74.4%; Average loss: 3.1006\n",
      "Iteration: 2975; Percent complete: 74.4%; Average loss: 3.0082\n",
      "Iteration: 2976; Percent complete: 74.4%; Average loss: 2.7345\n",
      "Iteration: 2977; Percent complete: 74.4%; Average loss: 2.8306\n",
      "Iteration: 2978; Percent complete: 74.5%; Average loss: 2.8274\n",
      "Iteration: 2979; Percent complete: 74.5%; Average loss: 2.8605\n",
      "Iteration: 2980; Percent complete: 74.5%; Average loss: 3.0234\n",
      "Iteration: 2981; Percent complete: 74.5%; Average loss: 3.0132\n",
      "Iteration: 2982; Percent complete: 74.6%; Average loss: 2.9144\n",
      "Iteration: 2983; Percent complete: 74.6%; Average loss: 2.8002\n",
      "Iteration: 2984; Percent complete: 74.6%; Average loss: 2.8792\n",
      "Iteration: 2985; Percent complete: 74.6%; Average loss: 2.9437\n",
      "Iteration: 2986; Percent complete: 74.7%; Average loss: 2.8563\n",
      "Iteration: 2987; Percent complete: 74.7%; Average loss: 2.7934\n",
      "Iteration: 2988; Percent complete: 74.7%; Average loss: 2.6238\n",
      "Iteration: 2989; Percent complete: 74.7%; Average loss: 2.9428\n",
      "Iteration: 2990; Percent complete: 74.8%; Average loss: 2.7998\n",
      "Iteration: 2991; Percent complete: 74.8%; Average loss: 2.8318\n",
      "Iteration: 2992; Percent complete: 74.8%; Average loss: 2.9339\n",
      "Iteration: 2993; Percent complete: 74.8%; Average loss: 2.8782\n",
      "Iteration: 2994; Percent complete: 74.9%; Average loss: 3.1637\n",
      "Iteration: 2995; Percent complete: 74.9%; Average loss: 3.1010\n",
      "Iteration: 2996; Percent complete: 74.9%; Average loss: 2.7193\n",
      "Iteration: 2997; Percent complete: 74.9%; Average loss: 2.6500\n",
      "Iteration: 2998; Percent complete: 75.0%; Average loss: 2.8133\n",
      "Iteration: 2999; Percent complete: 75.0%; Average loss: 2.7193\n",
      "Iteration: 3000; Percent complete: 75.0%; Average loss: 2.9309\n",
      "Iteration: 3001; Percent complete: 75.0%; Average loss: 2.7638\n",
      "Iteration: 3002; Percent complete: 75.0%; Average loss: 2.8418\n",
      "Iteration: 3003; Percent complete: 75.1%; Average loss: 2.5054\n",
      "Iteration: 3004; Percent complete: 75.1%; Average loss: 2.5728\n",
      "Iteration: 3005; Percent complete: 75.1%; Average loss: 2.9603\n",
      "Iteration: 3006; Percent complete: 75.1%; Average loss: 2.9576\n",
      "Iteration: 3007; Percent complete: 75.2%; Average loss: 2.9855\n",
      "Iteration: 3008; Percent complete: 75.2%; Average loss: 2.8845\n",
      "Iteration: 3009; Percent complete: 75.2%; Average loss: 2.9901\n",
      "Iteration: 3010; Percent complete: 75.2%; Average loss: 2.9357\n",
      "Iteration: 3011; Percent complete: 75.3%; Average loss: 3.0077\n",
      "Iteration: 3012; Percent complete: 75.3%; Average loss: 3.0804\n",
      "Iteration: 3013; Percent complete: 75.3%; Average loss: 2.7729\n",
      "Iteration: 3014; Percent complete: 75.3%; Average loss: 2.6889\n",
      "Iteration: 3015; Percent complete: 75.4%; Average loss: 2.7542\n",
      "Iteration: 3016; Percent complete: 75.4%; Average loss: 2.8191\n",
      "Iteration: 3017; Percent complete: 75.4%; Average loss: 2.8283\n",
      "Iteration: 3018; Percent complete: 75.4%; Average loss: 2.9287\n",
      "Iteration: 3019; Percent complete: 75.5%; Average loss: 2.9028\n",
      "Iteration: 3020; Percent complete: 75.5%; Average loss: 2.8650\n",
      "Iteration: 3021; Percent complete: 75.5%; Average loss: 3.0691\n",
      "Iteration: 3022; Percent complete: 75.5%; Average loss: 2.9317\n",
      "Iteration: 3023; Percent complete: 75.6%; Average loss: 2.9758\n",
      "Iteration: 3024; Percent complete: 75.6%; Average loss: 2.7602\n",
      "Iteration: 3025; Percent complete: 75.6%; Average loss: 2.9239\n",
      "Iteration: 3026; Percent complete: 75.6%; Average loss: 2.7535\n",
      "Iteration: 3027; Percent complete: 75.7%; Average loss: 3.1652\n",
      "Iteration: 3028; Percent complete: 75.7%; Average loss: 2.8869\n",
      "Iteration: 3029; Percent complete: 75.7%; Average loss: 3.0038\n",
      "Iteration: 3030; Percent complete: 75.8%; Average loss: 2.9468\n",
      "Iteration: 3031; Percent complete: 75.8%; Average loss: 2.8342\n",
      "Iteration: 3032; Percent complete: 75.8%; Average loss: 2.8659\n",
      "Iteration: 3033; Percent complete: 75.8%; Average loss: 3.0854\n",
      "Iteration: 3034; Percent complete: 75.8%; Average loss: 3.0557\n",
      "Iteration: 3035; Percent complete: 75.9%; Average loss: 3.0215\n",
      "Iteration: 3036; Percent complete: 75.9%; Average loss: 2.8933\n",
      "Iteration: 3037; Percent complete: 75.9%; Average loss: 2.8157\n",
      "Iteration: 3038; Percent complete: 75.9%; Average loss: 2.8651\n",
      "Iteration: 3039; Percent complete: 76.0%; Average loss: 3.0135\n",
      "Iteration: 3040; Percent complete: 76.0%; Average loss: 2.8053\n",
      "Iteration: 3041; Percent complete: 76.0%; Average loss: 2.7221\n",
      "Iteration: 3042; Percent complete: 76.0%; Average loss: 2.8089\n",
      "Iteration: 3043; Percent complete: 76.1%; Average loss: 3.0255\n",
      "Iteration: 3044; Percent complete: 76.1%; Average loss: 2.8085\n",
      "Iteration: 3045; Percent complete: 76.1%; Average loss: 2.6476\n",
      "Iteration: 3046; Percent complete: 76.1%; Average loss: 2.6842\n",
      "Iteration: 3047; Percent complete: 76.2%; Average loss: 2.7244\n",
      "Iteration: 3048; Percent complete: 76.2%; Average loss: 3.0926\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 3049; Percent complete: 76.2%; Average loss: 2.8270\n",
      "Iteration: 3050; Percent complete: 76.2%; Average loss: 2.7571\n",
      "Iteration: 3051; Percent complete: 76.3%; Average loss: 3.0588\n",
      "Iteration: 3052; Percent complete: 76.3%; Average loss: 3.2423\n",
      "Iteration: 3053; Percent complete: 76.3%; Average loss: 3.0966\n",
      "Iteration: 3054; Percent complete: 76.3%; Average loss: 2.9807\n",
      "Iteration: 3055; Percent complete: 76.4%; Average loss: 3.0034\n",
      "Iteration: 3056; Percent complete: 76.4%; Average loss: 2.7312\n",
      "Iteration: 3057; Percent complete: 76.4%; Average loss: 2.9805\n",
      "Iteration: 3058; Percent complete: 76.4%; Average loss: 2.8954\n",
      "Iteration: 3059; Percent complete: 76.5%; Average loss: 3.0720\n",
      "Iteration: 3060; Percent complete: 76.5%; Average loss: 2.7584\n",
      "Iteration: 3061; Percent complete: 76.5%; Average loss: 2.9128\n",
      "Iteration: 3062; Percent complete: 76.5%; Average loss: 2.7813\n",
      "Iteration: 3063; Percent complete: 76.6%; Average loss: 2.9107\n",
      "Iteration: 3064; Percent complete: 76.6%; Average loss: 2.7381\n",
      "Iteration: 3065; Percent complete: 76.6%; Average loss: 3.0679\n",
      "Iteration: 3066; Percent complete: 76.6%; Average loss: 2.8072\n",
      "Iteration: 3067; Percent complete: 76.7%; Average loss: 2.9638\n",
      "Iteration: 3068; Percent complete: 76.7%; Average loss: 3.0554\n",
      "Iteration: 3069; Percent complete: 76.7%; Average loss: 2.5754\n",
      "Iteration: 3070; Percent complete: 76.8%; Average loss: 2.9030\n",
      "Iteration: 3071; Percent complete: 76.8%; Average loss: 2.8616\n",
      "Iteration: 3072; Percent complete: 76.8%; Average loss: 2.8700\n",
      "Iteration: 3073; Percent complete: 76.8%; Average loss: 2.8939\n",
      "Iteration: 3074; Percent complete: 76.8%; Average loss: 2.9212\n",
      "Iteration: 3075; Percent complete: 76.9%; Average loss: 2.6892\n",
      "Iteration: 3076; Percent complete: 76.9%; Average loss: 2.8794\n",
      "Iteration: 3077; Percent complete: 76.9%; Average loss: 2.7051\n",
      "Iteration: 3078; Percent complete: 77.0%; Average loss: 2.9584\n",
      "Iteration: 3079; Percent complete: 77.0%; Average loss: 2.6869\n",
      "Iteration: 3080; Percent complete: 77.0%; Average loss: 2.8431\n",
      "Iteration: 3081; Percent complete: 77.0%; Average loss: 2.6975\n",
      "Iteration: 3082; Percent complete: 77.0%; Average loss: 2.9033\n",
      "Iteration: 3083; Percent complete: 77.1%; Average loss: 2.9259\n",
      "Iteration: 3084; Percent complete: 77.1%; Average loss: 3.1050\n",
      "Iteration: 3085; Percent complete: 77.1%; Average loss: 2.7745\n",
      "Iteration: 3086; Percent complete: 77.1%; Average loss: 2.8549\n",
      "Iteration: 3087; Percent complete: 77.2%; Average loss: 3.1364\n",
      "Iteration: 3088; Percent complete: 77.2%; Average loss: 2.9329\n",
      "Iteration: 3089; Percent complete: 77.2%; Average loss: 3.0613\n",
      "Iteration: 3090; Percent complete: 77.2%; Average loss: 2.7682\n",
      "Iteration: 3091; Percent complete: 77.3%; Average loss: 3.0075\n",
      "Iteration: 3092; Percent complete: 77.3%; Average loss: 2.9233\n",
      "Iteration: 3093; Percent complete: 77.3%; Average loss: 2.5335\n",
      "Iteration: 3094; Percent complete: 77.3%; Average loss: 2.8062\n",
      "Iteration: 3095; Percent complete: 77.4%; Average loss: 2.9055\n",
      "Iteration: 3096; Percent complete: 77.4%; Average loss: 2.9492\n",
      "Iteration: 3097; Percent complete: 77.4%; Average loss: 2.7703\n",
      "Iteration: 3098; Percent complete: 77.5%; Average loss: 2.7605\n",
      "Iteration: 3099; Percent complete: 77.5%; Average loss: 2.8513\n",
      "Iteration: 3100; Percent complete: 77.5%; Average loss: 2.9147\n",
      "Iteration: 3101; Percent complete: 77.5%; Average loss: 2.8813\n",
      "Iteration: 3102; Percent complete: 77.5%; Average loss: 3.0247\n",
      "Iteration: 3103; Percent complete: 77.6%; Average loss: 2.8368\n",
      "Iteration: 3104; Percent complete: 77.6%; Average loss: 2.7065\n",
      "Iteration: 3105; Percent complete: 77.6%; Average loss: 2.8277\n",
      "Iteration: 3106; Percent complete: 77.6%; Average loss: 3.1052\n",
      "Iteration: 3107; Percent complete: 77.7%; Average loss: 3.0114\n",
      "Iteration: 3108; Percent complete: 77.7%; Average loss: 2.9342\n",
      "Iteration: 3109; Percent complete: 77.7%; Average loss: 2.7294\n",
      "Iteration: 3110; Percent complete: 77.8%; Average loss: 2.9432\n",
      "Iteration: 3111; Percent complete: 77.8%; Average loss: 2.7941\n",
      "Iteration: 3112; Percent complete: 77.8%; Average loss: 2.9775\n",
      "Iteration: 3113; Percent complete: 77.8%; Average loss: 2.9150\n",
      "Iteration: 3114; Percent complete: 77.8%; Average loss: 2.8040\n",
      "Iteration: 3115; Percent complete: 77.9%; Average loss: 2.5945\n",
      "Iteration: 3116; Percent complete: 77.9%; Average loss: 2.9625\n",
      "Iteration: 3117; Percent complete: 77.9%; Average loss: 3.0275\n",
      "Iteration: 3118; Percent complete: 78.0%; Average loss: 2.9392\n",
      "Iteration: 3119; Percent complete: 78.0%; Average loss: 2.7534\n",
      "Iteration: 3120; Percent complete: 78.0%; Average loss: 3.0062\n",
      "Iteration: 3121; Percent complete: 78.0%; Average loss: 3.0392\n",
      "Iteration: 3122; Percent complete: 78.0%; Average loss: 2.7843\n",
      "Iteration: 3123; Percent complete: 78.1%; Average loss: 2.7854\n",
      "Iteration: 3124; Percent complete: 78.1%; Average loss: 2.9125\n",
      "Iteration: 3125; Percent complete: 78.1%; Average loss: 2.7496\n",
      "Iteration: 3126; Percent complete: 78.1%; Average loss: 2.7070\n",
      "Iteration: 3127; Percent complete: 78.2%; Average loss: 2.9529\n",
      "Iteration: 3128; Percent complete: 78.2%; Average loss: 2.7851\n",
      "Iteration: 3129; Percent complete: 78.2%; Average loss: 2.8731\n",
      "Iteration: 3130; Percent complete: 78.2%; Average loss: 3.0912\n",
      "Iteration: 3131; Percent complete: 78.3%; Average loss: 2.6287\n",
      "Iteration: 3132; Percent complete: 78.3%; Average loss: 2.7438\n",
      "Iteration: 3133; Percent complete: 78.3%; Average loss: 2.7206\n",
      "Iteration: 3134; Percent complete: 78.3%; Average loss: 2.9183\n",
      "Iteration: 3135; Percent complete: 78.4%; Average loss: 3.1679\n",
      "Iteration: 3136; Percent complete: 78.4%; Average loss: 2.9150\n",
      "Iteration: 3137; Percent complete: 78.4%; Average loss: 2.7868\n",
      "Iteration: 3138; Percent complete: 78.5%; Average loss: 2.6881\n",
      "Iteration: 3139; Percent complete: 78.5%; Average loss: 2.7533\n",
      "Iteration: 3140; Percent complete: 78.5%; Average loss: 2.7371\n",
      "Iteration: 3141; Percent complete: 78.5%; Average loss: 3.0104\n",
      "Iteration: 3142; Percent complete: 78.5%; Average loss: 2.9018\n",
      "Iteration: 3143; Percent complete: 78.6%; Average loss: 3.0068\n",
      "Iteration: 3144; Percent complete: 78.6%; Average loss: 3.0486\n",
      "Iteration: 3145; Percent complete: 78.6%; Average loss: 3.0497\n",
      "Iteration: 3146; Percent complete: 78.6%; Average loss: 2.6719\n",
      "Iteration: 3147; Percent complete: 78.7%; Average loss: 2.8974\n",
      "Iteration: 3148; Percent complete: 78.7%; Average loss: 2.7934\n",
      "Iteration: 3149; Percent complete: 78.7%; Average loss: 2.6603\n",
      "Iteration: 3150; Percent complete: 78.8%; Average loss: 2.6929\n",
      "Iteration: 3151; Percent complete: 78.8%; Average loss: 2.7334\n",
      "Iteration: 3152; Percent complete: 78.8%; Average loss: 2.9340\n",
      "Iteration: 3153; Percent complete: 78.8%; Average loss: 2.9610\n",
      "Iteration: 3154; Percent complete: 78.8%; Average loss: 2.7363\n",
      "Iteration: 3155; Percent complete: 78.9%; Average loss: 2.7550\n",
      "Iteration: 3156; Percent complete: 78.9%; Average loss: 2.5778\n",
      "Iteration: 3157; Percent complete: 78.9%; Average loss: 2.7526\n",
      "Iteration: 3158; Percent complete: 79.0%; Average loss: 2.7522\n",
      "Iteration: 3159; Percent complete: 79.0%; Average loss: 2.8850\n",
      "Iteration: 3160; Percent complete: 79.0%; Average loss: 2.9679\n",
      "Iteration: 3161; Percent complete: 79.0%; Average loss: 2.7467\n",
      "Iteration: 3162; Percent complete: 79.0%; Average loss: 2.9456\n",
      "Iteration: 3163; Percent complete: 79.1%; Average loss: 2.8227\n",
      "Iteration: 3164; Percent complete: 79.1%; Average loss: 2.8470\n",
      "Iteration: 3165; Percent complete: 79.1%; Average loss: 2.8114\n",
      "Iteration: 3166; Percent complete: 79.1%; Average loss: 2.9061\n",
      "Iteration: 3167; Percent complete: 79.2%; Average loss: 2.6650\n",
      "Iteration: 3168; Percent complete: 79.2%; Average loss: 2.6914\n",
      "Iteration: 3169; Percent complete: 79.2%; Average loss: 2.7249\n",
      "Iteration: 3170; Percent complete: 79.2%; Average loss: 2.7198\n",
      "Iteration: 3171; Percent complete: 79.3%; Average loss: 2.6902\n",
      "Iteration: 3172; Percent complete: 79.3%; Average loss: 2.8853\n",
      "Iteration: 3173; Percent complete: 79.3%; Average loss: 2.8941\n",
      "Iteration: 3174; Percent complete: 79.3%; Average loss: 2.7458\n",
      "Iteration: 3175; Percent complete: 79.4%; Average loss: 2.8556\n",
      "Iteration: 3176; Percent complete: 79.4%; Average loss: 2.4954\n",
      "Iteration: 3177; Percent complete: 79.4%; Average loss: 2.9753\n",
      "Iteration: 3178; Percent complete: 79.5%; Average loss: 3.1065\n",
      "Iteration: 3179; Percent complete: 79.5%; Average loss: 2.7607\n",
      "Iteration: 3180; Percent complete: 79.5%; Average loss: 2.7321\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 3181; Percent complete: 79.5%; Average loss: 2.6924\n",
      "Iteration: 3182; Percent complete: 79.5%; Average loss: 3.1911\n",
      "Iteration: 3183; Percent complete: 79.6%; Average loss: 2.9284\n",
      "Iteration: 3184; Percent complete: 79.6%; Average loss: 2.9666\n",
      "Iteration: 3185; Percent complete: 79.6%; Average loss: 2.9864\n",
      "Iteration: 3186; Percent complete: 79.7%; Average loss: 2.8121\n",
      "Iteration: 3187; Percent complete: 79.7%; Average loss: 3.0195\n",
      "Iteration: 3188; Percent complete: 79.7%; Average loss: 2.8033\n",
      "Iteration: 3189; Percent complete: 79.7%; Average loss: 2.7731\n",
      "Iteration: 3190; Percent complete: 79.8%; Average loss: 2.7954\n",
      "Iteration: 3191; Percent complete: 79.8%; Average loss: 2.7084\n",
      "Iteration: 3192; Percent complete: 79.8%; Average loss: 2.7469\n",
      "Iteration: 3193; Percent complete: 79.8%; Average loss: 2.7733\n",
      "Iteration: 3194; Percent complete: 79.8%; Average loss: 2.6893\n",
      "Iteration: 3195; Percent complete: 79.9%; Average loss: 3.0489\n",
      "Iteration: 3196; Percent complete: 79.9%; Average loss: 3.0109\n",
      "Iteration: 3197; Percent complete: 79.9%; Average loss: 2.7825\n",
      "Iteration: 3198; Percent complete: 80.0%; Average loss: 2.7084\n",
      "Iteration: 3199; Percent complete: 80.0%; Average loss: 2.8265\n",
      "Iteration: 3200; Percent complete: 80.0%; Average loss: 2.8915\n",
      "Iteration: 3201; Percent complete: 80.0%; Average loss: 2.8578\n",
      "Iteration: 3202; Percent complete: 80.0%; Average loss: 2.9258\n",
      "Iteration: 3203; Percent complete: 80.1%; Average loss: 2.8219\n",
      "Iteration: 3204; Percent complete: 80.1%; Average loss: 2.8322\n",
      "Iteration: 3205; Percent complete: 80.1%; Average loss: 2.7415\n",
      "Iteration: 3206; Percent complete: 80.2%; Average loss: 2.8096\n",
      "Iteration: 3207; Percent complete: 80.2%; Average loss: 2.8393\n",
      "Iteration: 3208; Percent complete: 80.2%; Average loss: 2.6687\n",
      "Iteration: 3209; Percent complete: 80.2%; Average loss: 2.8089\n",
      "Iteration: 3210; Percent complete: 80.2%; Average loss: 2.6652\n",
      "Iteration: 3211; Percent complete: 80.3%; Average loss: 2.8007\n",
      "Iteration: 3212; Percent complete: 80.3%; Average loss: 2.7241\n",
      "Iteration: 3213; Percent complete: 80.3%; Average loss: 2.6850\n",
      "Iteration: 3214; Percent complete: 80.3%; Average loss: 2.9166\n",
      "Iteration: 3215; Percent complete: 80.4%; Average loss: 2.6910\n",
      "Iteration: 3216; Percent complete: 80.4%; Average loss: 2.8645\n",
      "Iteration: 3217; Percent complete: 80.4%; Average loss: 2.7067\n",
      "Iteration: 3218; Percent complete: 80.5%; Average loss: 3.0660\n",
      "Iteration: 3219; Percent complete: 80.5%; Average loss: 2.6875\n",
      "Iteration: 3220; Percent complete: 80.5%; Average loss: 2.7681\n",
      "Iteration: 3221; Percent complete: 80.5%; Average loss: 2.8989\n",
      "Iteration: 3222; Percent complete: 80.5%; Average loss: 2.4552\n",
      "Iteration: 3223; Percent complete: 80.6%; Average loss: 2.8904\n",
      "Iteration: 3224; Percent complete: 80.6%; Average loss: 2.7143\n",
      "Iteration: 3225; Percent complete: 80.6%; Average loss: 3.1704\n",
      "Iteration: 3226; Percent complete: 80.7%; Average loss: 2.7384\n",
      "Iteration: 3227; Percent complete: 80.7%; Average loss: 2.7592\n",
      "Iteration: 3228; Percent complete: 80.7%; Average loss: 2.9008\n",
      "Iteration: 3229; Percent complete: 80.7%; Average loss: 2.8823\n",
      "Iteration: 3230; Percent complete: 80.8%; Average loss: 2.7078\n",
      "Iteration: 3231; Percent complete: 80.8%; Average loss: 2.7250\n",
      "Iteration: 3232; Percent complete: 80.8%; Average loss: 2.9043\n",
      "Iteration: 3233; Percent complete: 80.8%; Average loss: 2.8902\n",
      "Iteration: 3234; Percent complete: 80.8%; Average loss: 2.9211\n",
      "Iteration: 3235; Percent complete: 80.9%; Average loss: 2.7731\n",
      "Iteration: 3236; Percent complete: 80.9%; Average loss: 2.8056\n",
      "Iteration: 3237; Percent complete: 80.9%; Average loss: 2.9446\n",
      "Iteration: 3238; Percent complete: 81.0%; Average loss: 2.8939\n",
      "Iteration: 3239; Percent complete: 81.0%; Average loss: 2.8668\n",
      "Iteration: 3240; Percent complete: 81.0%; Average loss: 2.7240\n",
      "Iteration: 3241; Percent complete: 81.0%; Average loss: 2.9436\n",
      "Iteration: 3242; Percent complete: 81.0%; Average loss: 2.9491\n",
      "Iteration: 3243; Percent complete: 81.1%; Average loss: 2.8313\n",
      "Iteration: 3244; Percent complete: 81.1%; Average loss: 2.6787\n",
      "Iteration: 3245; Percent complete: 81.1%; Average loss: 2.8275\n",
      "Iteration: 3246; Percent complete: 81.2%; Average loss: 2.8726\n",
      "Iteration: 3247; Percent complete: 81.2%; Average loss: 2.7840\n",
      "Iteration: 3248; Percent complete: 81.2%; Average loss: 2.7337\n",
      "Iteration: 3249; Percent complete: 81.2%; Average loss: 2.6197\n",
      "Iteration: 3250; Percent complete: 81.2%; Average loss: 2.7746\n",
      "Iteration: 3251; Percent complete: 81.3%; Average loss: 2.8080\n",
      "Iteration: 3252; Percent complete: 81.3%; Average loss: 2.8339\n",
      "Iteration: 3253; Percent complete: 81.3%; Average loss: 2.8465\n",
      "Iteration: 3254; Percent complete: 81.3%; Average loss: 2.7024\n",
      "Iteration: 3255; Percent complete: 81.4%; Average loss: 2.7166\n",
      "Iteration: 3256; Percent complete: 81.4%; Average loss: 2.7325\n",
      "Iteration: 3257; Percent complete: 81.4%; Average loss: 2.7589\n",
      "Iteration: 3258; Percent complete: 81.5%; Average loss: 2.8432\n",
      "Iteration: 3259; Percent complete: 81.5%; Average loss: 2.8825\n",
      "Iteration: 3260; Percent complete: 81.5%; Average loss: 2.7154\n",
      "Iteration: 3261; Percent complete: 81.5%; Average loss: 3.1141\n",
      "Iteration: 3262; Percent complete: 81.5%; Average loss: 2.5136\n",
      "Iteration: 3263; Percent complete: 81.6%; Average loss: 2.7622\n",
      "Iteration: 3264; Percent complete: 81.6%; Average loss: 2.8958\n",
      "Iteration: 3265; Percent complete: 81.6%; Average loss: 2.7280\n",
      "Iteration: 3266; Percent complete: 81.7%; Average loss: 2.5670\n",
      "Iteration: 3267; Percent complete: 81.7%; Average loss: 2.8166\n",
      "Iteration: 3268; Percent complete: 81.7%; Average loss: 2.9100\n",
      "Iteration: 3269; Percent complete: 81.7%; Average loss: 2.9686\n",
      "Iteration: 3270; Percent complete: 81.8%; Average loss: 2.7447\n",
      "Iteration: 3271; Percent complete: 81.8%; Average loss: 2.7120\n",
      "Iteration: 3272; Percent complete: 81.8%; Average loss: 2.7440\n",
      "Iteration: 3273; Percent complete: 81.8%; Average loss: 2.7651\n",
      "Iteration: 3274; Percent complete: 81.8%; Average loss: 2.8138\n",
      "Iteration: 3275; Percent complete: 81.9%; Average loss: 2.7952\n",
      "Iteration: 3276; Percent complete: 81.9%; Average loss: 2.7112\n",
      "Iteration: 3277; Percent complete: 81.9%; Average loss: 2.7548\n",
      "Iteration: 3278; Percent complete: 82.0%; Average loss: 2.6638\n",
      "Iteration: 3279; Percent complete: 82.0%; Average loss: 2.7349\n",
      "Iteration: 3280; Percent complete: 82.0%; Average loss: 2.6503\n",
      "Iteration: 3281; Percent complete: 82.0%; Average loss: 2.8031\n",
      "Iteration: 3282; Percent complete: 82.0%; Average loss: 2.5924\n",
      "Iteration: 3283; Percent complete: 82.1%; Average loss: 2.7504\n",
      "Iteration: 3284; Percent complete: 82.1%; Average loss: 2.8876\n",
      "Iteration: 3285; Percent complete: 82.1%; Average loss: 2.9053\n",
      "Iteration: 3286; Percent complete: 82.2%; Average loss: 2.5148\n",
      "Iteration: 3287; Percent complete: 82.2%; Average loss: 2.6570\n",
      "Iteration: 3288; Percent complete: 82.2%; Average loss: 2.7847\n",
      "Iteration: 3289; Percent complete: 82.2%; Average loss: 2.8660\n",
      "Iteration: 3290; Percent complete: 82.2%; Average loss: 2.8672\n",
      "Iteration: 3291; Percent complete: 82.3%; Average loss: 2.8990\n",
      "Iteration: 3292; Percent complete: 82.3%; Average loss: 2.5532\n",
      "Iteration: 3293; Percent complete: 82.3%; Average loss: 2.9507\n",
      "Iteration: 3294; Percent complete: 82.3%; Average loss: 2.8698\n",
      "Iteration: 3295; Percent complete: 82.4%; Average loss: 2.6903\n",
      "Iteration: 3296; Percent complete: 82.4%; Average loss: 2.9706\n",
      "Iteration: 3297; Percent complete: 82.4%; Average loss: 3.0032\n",
      "Iteration: 3298; Percent complete: 82.5%; Average loss: 2.6907\n",
      "Iteration: 3299; Percent complete: 82.5%; Average loss: 2.8250\n",
      "Iteration: 3300; Percent complete: 82.5%; Average loss: 2.9767\n",
      "Iteration: 3301; Percent complete: 82.5%; Average loss: 2.7479\n",
      "Iteration: 3302; Percent complete: 82.5%; Average loss: 2.9291\n",
      "Iteration: 3303; Percent complete: 82.6%; Average loss: 2.6664\n",
      "Iteration: 3304; Percent complete: 82.6%; Average loss: 2.6313\n",
      "Iteration: 3305; Percent complete: 82.6%; Average loss: 2.6350\n",
      "Iteration: 3306; Percent complete: 82.7%; Average loss: 2.7353\n",
      "Iteration: 3307; Percent complete: 82.7%; Average loss: 2.7442\n",
      "Iteration: 3308; Percent complete: 82.7%; Average loss: 2.5837\n",
      "Iteration: 3309; Percent complete: 82.7%; Average loss: 2.9293\n",
      "Iteration: 3310; Percent complete: 82.8%; Average loss: 2.7207\n",
      "Iteration: 3311; Percent complete: 82.8%; Average loss: 2.7979\n",
      "Iteration: 3312; Percent complete: 82.8%; Average loss: 2.9530\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 3313; Percent complete: 82.8%; Average loss: 2.7533\n",
      "Iteration: 3314; Percent complete: 82.8%; Average loss: 2.6540\n",
      "Iteration: 3315; Percent complete: 82.9%; Average loss: 2.5413\n",
      "Iteration: 3316; Percent complete: 82.9%; Average loss: 2.9569\n",
      "Iteration: 3317; Percent complete: 82.9%; Average loss: 2.8302\n",
      "Iteration: 3318; Percent complete: 83.0%; Average loss: 2.5789\n",
      "Iteration: 3319; Percent complete: 83.0%; Average loss: 2.8530\n",
      "Iteration: 3320; Percent complete: 83.0%; Average loss: 2.5086\n",
      "Iteration: 3321; Percent complete: 83.0%; Average loss: 2.9832\n",
      "Iteration: 3322; Percent complete: 83.0%; Average loss: 2.7571\n",
      "Iteration: 3323; Percent complete: 83.1%; Average loss: 2.7648\n",
      "Iteration: 3324; Percent complete: 83.1%; Average loss: 2.6254\n",
      "Iteration: 3325; Percent complete: 83.1%; Average loss: 2.7147\n",
      "Iteration: 3326; Percent complete: 83.2%; Average loss: 2.9317\n",
      "Iteration: 3327; Percent complete: 83.2%; Average loss: 2.5970\n",
      "Iteration: 3328; Percent complete: 83.2%; Average loss: 2.8013\n",
      "Iteration: 3329; Percent complete: 83.2%; Average loss: 3.1025\n",
      "Iteration: 3330; Percent complete: 83.2%; Average loss: 2.5955\n",
      "Iteration: 3331; Percent complete: 83.3%; Average loss: 2.7957\n",
      "Iteration: 3332; Percent complete: 83.3%; Average loss: 2.8502\n",
      "Iteration: 3333; Percent complete: 83.3%; Average loss: 2.5705\n",
      "Iteration: 3334; Percent complete: 83.4%; Average loss: 2.8475\n",
      "Iteration: 3335; Percent complete: 83.4%; Average loss: 2.8496\n",
      "Iteration: 3336; Percent complete: 83.4%; Average loss: 2.8917\n",
      "Iteration: 3337; Percent complete: 83.4%; Average loss: 2.7177\n",
      "Iteration: 3338; Percent complete: 83.5%; Average loss: 2.9047\n",
      "Iteration: 3339; Percent complete: 83.5%; Average loss: 2.7798\n",
      "Iteration: 3340; Percent complete: 83.5%; Average loss: 2.7066\n",
      "Iteration: 3341; Percent complete: 83.5%; Average loss: 2.8652\n",
      "Iteration: 3342; Percent complete: 83.5%; Average loss: 2.7338\n",
      "Iteration: 3343; Percent complete: 83.6%; Average loss: 2.9613\n",
      "Iteration: 3344; Percent complete: 83.6%; Average loss: 2.9736\n",
      "Iteration: 3345; Percent complete: 83.6%; Average loss: 2.7395\n",
      "Iteration: 3346; Percent complete: 83.7%; Average loss: 2.6232\n",
      "Iteration: 3347; Percent complete: 83.7%; Average loss: 2.6958\n",
      "Iteration: 3348; Percent complete: 83.7%; Average loss: 2.7995\n",
      "Iteration: 3349; Percent complete: 83.7%; Average loss: 2.5238\n",
      "Iteration: 3350; Percent complete: 83.8%; Average loss: 2.5970\n",
      "Iteration: 3351; Percent complete: 83.8%; Average loss: 2.6735\n",
      "Iteration: 3352; Percent complete: 83.8%; Average loss: 2.8192\n",
      "Iteration: 3353; Percent complete: 83.8%; Average loss: 2.7790\n",
      "Iteration: 3354; Percent complete: 83.9%; Average loss: 2.5137\n",
      "Iteration: 3355; Percent complete: 83.9%; Average loss: 2.8376\n",
      "Iteration: 3356; Percent complete: 83.9%; Average loss: 2.4038\n",
      "Iteration: 3357; Percent complete: 83.9%; Average loss: 2.5589\n",
      "Iteration: 3358; Percent complete: 84.0%; Average loss: 2.7389\n",
      "Iteration: 3359; Percent complete: 84.0%; Average loss: 2.7260\n",
      "Iteration: 3360; Percent complete: 84.0%; Average loss: 2.7453\n",
      "Iteration: 3361; Percent complete: 84.0%; Average loss: 2.9452\n",
      "Iteration: 3362; Percent complete: 84.0%; Average loss: 2.7185\n",
      "Iteration: 3363; Percent complete: 84.1%; Average loss: 2.8788\n",
      "Iteration: 3364; Percent complete: 84.1%; Average loss: 2.6679\n",
      "Iteration: 3365; Percent complete: 84.1%; Average loss: 2.6648\n",
      "Iteration: 3366; Percent complete: 84.2%; Average loss: 2.9574\n",
      "Iteration: 3367; Percent complete: 84.2%; Average loss: 3.0544\n",
      "Iteration: 3368; Percent complete: 84.2%; Average loss: 2.8243\n",
      "Iteration: 3369; Percent complete: 84.2%; Average loss: 3.0405\n",
      "Iteration: 3370; Percent complete: 84.2%; Average loss: 2.8771\n",
      "Iteration: 3371; Percent complete: 84.3%; Average loss: 2.8166\n",
      "Iteration: 3372; Percent complete: 84.3%; Average loss: 2.8110\n",
      "Iteration: 3373; Percent complete: 84.3%; Average loss: 2.8128\n",
      "Iteration: 3374; Percent complete: 84.4%; Average loss: 2.8865\n",
      "Iteration: 3375; Percent complete: 84.4%; Average loss: 2.8139\n",
      "Iteration: 3376; Percent complete: 84.4%; Average loss: 2.7552\n",
      "Iteration: 3377; Percent complete: 84.4%; Average loss: 2.6730\n",
      "Iteration: 3378; Percent complete: 84.5%; Average loss: 2.8069\n",
      "Iteration: 3379; Percent complete: 84.5%; Average loss: 2.8825\n",
      "Iteration: 3380; Percent complete: 84.5%; Average loss: 2.9261\n",
      "Iteration: 3381; Percent complete: 84.5%; Average loss: 2.7741\n",
      "Iteration: 3382; Percent complete: 84.5%; Average loss: 2.7152\n",
      "Iteration: 3383; Percent complete: 84.6%; Average loss: 2.7532\n",
      "Iteration: 3384; Percent complete: 84.6%; Average loss: 2.6528\n",
      "Iteration: 3385; Percent complete: 84.6%; Average loss: 2.8218\n",
      "Iteration: 3386; Percent complete: 84.7%; Average loss: 2.6048\n",
      "Iteration: 3387; Percent complete: 84.7%; Average loss: 2.7988\n",
      "Iteration: 3388; Percent complete: 84.7%; Average loss: 2.7428\n",
      "Iteration: 3389; Percent complete: 84.7%; Average loss: 2.8439\n",
      "Iteration: 3390; Percent complete: 84.8%; Average loss: 2.9253\n",
      "Iteration: 3391; Percent complete: 84.8%; Average loss: 2.6896\n",
      "Iteration: 3392; Percent complete: 84.8%; Average loss: 2.8980\n",
      "Iteration: 3393; Percent complete: 84.8%; Average loss: 2.7947\n",
      "Iteration: 3394; Percent complete: 84.9%; Average loss: 2.6869\n",
      "Iteration: 3395; Percent complete: 84.9%; Average loss: 2.8060\n",
      "Iteration: 3396; Percent complete: 84.9%; Average loss: 2.9951\n",
      "Iteration: 3397; Percent complete: 84.9%; Average loss: 2.7267\n",
      "Iteration: 3398; Percent complete: 85.0%; Average loss: 2.8212\n",
      "Iteration: 3399; Percent complete: 85.0%; Average loss: 2.6318\n",
      "Iteration: 3400; Percent complete: 85.0%; Average loss: 2.9036\n",
      "Iteration: 3401; Percent complete: 85.0%; Average loss: 2.6912\n",
      "Iteration: 3402; Percent complete: 85.0%; Average loss: 2.8174\n",
      "Iteration: 3403; Percent complete: 85.1%; Average loss: 3.0670\n",
      "Iteration: 3404; Percent complete: 85.1%; Average loss: 2.6938\n",
      "Iteration: 3405; Percent complete: 85.1%; Average loss: 2.7776\n",
      "Iteration: 3406; Percent complete: 85.2%; Average loss: 2.6494\n",
      "Iteration: 3407; Percent complete: 85.2%; Average loss: 2.3436\n",
      "Iteration: 3408; Percent complete: 85.2%; Average loss: 2.6071\n",
      "Iteration: 3409; Percent complete: 85.2%; Average loss: 2.7010\n",
      "Iteration: 3410; Percent complete: 85.2%; Average loss: 2.8126\n",
      "Iteration: 3411; Percent complete: 85.3%; Average loss: 2.7163\n",
      "Iteration: 3412; Percent complete: 85.3%; Average loss: 2.6288\n",
      "Iteration: 3413; Percent complete: 85.3%; Average loss: 2.4918\n",
      "Iteration: 3414; Percent complete: 85.4%; Average loss: 2.7570\n",
      "Iteration: 3415; Percent complete: 85.4%; Average loss: 2.6905\n",
      "Iteration: 3416; Percent complete: 85.4%; Average loss: 2.5595\n",
      "Iteration: 3417; Percent complete: 85.4%; Average loss: 2.9379\n",
      "Iteration: 3418; Percent complete: 85.5%; Average loss: 2.9735\n",
      "Iteration: 3419; Percent complete: 85.5%; Average loss: 2.5942\n",
      "Iteration: 3420; Percent complete: 85.5%; Average loss: 2.6832\n",
      "Iteration: 3421; Percent complete: 85.5%; Average loss: 2.6815\n",
      "Iteration: 3422; Percent complete: 85.5%; Average loss: 2.8764\n",
      "Iteration: 3423; Percent complete: 85.6%; Average loss: 3.0979\n",
      "Iteration: 3424; Percent complete: 85.6%; Average loss: 2.8519\n",
      "Iteration: 3425; Percent complete: 85.6%; Average loss: 2.8940\n",
      "Iteration: 3426; Percent complete: 85.7%; Average loss: 2.7331\n",
      "Iteration: 3427; Percent complete: 85.7%; Average loss: 2.6623\n",
      "Iteration: 3428; Percent complete: 85.7%; Average loss: 2.6391\n",
      "Iteration: 3429; Percent complete: 85.7%; Average loss: 2.5757\n",
      "Iteration: 3430; Percent complete: 85.8%; Average loss: 2.6707\n",
      "Iteration: 3431; Percent complete: 85.8%; Average loss: 2.7163\n",
      "Iteration: 3432; Percent complete: 85.8%; Average loss: 2.7594\n",
      "Iteration: 3433; Percent complete: 85.8%; Average loss: 2.7262\n",
      "Iteration: 3434; Percent complete: 85.9%; Average loss: 2.7754\n",
      "Iteration: 3435; Percent complete: 85.9%; Average loss: 2.6924\n",
      "Iteration: 3436; Percent complete: 85.9%; Average loss: 2.8540\n",
      "Iteration: 3437; Percent complete: 85.9%; Average loss: 2.9236\n",
      "Iteration: 3438; Percent complete: 86.0%; Average loss: 3.0113\n",
      "Iteration: 3439; Percent complete: 86.0%; Average loss: 2.7075\n",
      "Iteration: 3440; Percent complete: 86.0%; Average loss: 2.5628\n",
      "Iteration: 3441; Percent complete: 86.0%; Average loss: 2.8785\n",
      "Iteration: 3442; Percent complete: 86.1%; Average loss: 2.8080\n",
      "Iteration: 3443; Percent complete: 86.1%; Average loss: 2.6297\n",
      "Iteration: 3444; Percent complete: 86.1%; Average loss: 2.5653\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 3445; Percent complete: 86.1%; Average loss: 2.5637\n",
      "Iteration: 3446; Percent complete: 86.2%; Average loss: 2.5547\n",
      "Iteration: 3447; Percent complete: 86.2%; Average loss: 2.9249\n",
      "Iteration: 3448; Percent complete: 86.2%; Average loss: 2.8795\n",
      "Iteration: 3449; Percent complete: 86.2%; Average loss: 2.5120\n",
      "Iteration: 3450; Percent complete: 86.2%; Average loss: 2.7425\n",
      "Iteration: 3451; Percent complete: 86.3%; Average loss: 2.7665\n",
      "Iteration: 3452; Percent complete: 86.3%; Average loss: 2.5821\n",
      "Iteration: 3453; Percent complete: 86.3%; Average loss: 3.0482\n",
      "Iteration: 3454; Percent complete: 86.4%; Average loss: 2.7300\n",
      "Iteration: 3455; Percent complete: 86.4%; Average loss: 2.6291\n",
      "Iteration: 3456; Percent complete: 86.4%; Average loss: 2.7337\n",
      "Iteration: 3457; Percent complete: 86.4%; Average loss: 2.7158\n",
      "Iteration: 3458; Percent complete: 86.5%; Average loss: 2.7538\n",
      "Iteration: 3459; Percent complete: 86.5%; Average loss: 2.7563\n",
      "Iteration: 3460; Percent complete: 86.5%; Average loss: 2.6931\n",
      "Iteration: 3461; Percent complete: 86.5%; Average loss: 2.9425\n",
      "Iteration: 3462; Percent complete: 86.6%; Average loss: 2.7795\n",
      "Iteration: 3463; Percent complete: 86.6%; Average loss: 2.8960\n",
      "Iteration: 3464; Percent complete: 86.6%; Average loss: 2.8703\n",
      "Iteration: 3465; Percent complete: 86.6%; Average loss: 2.8963\n",
      "Iteration: 3466; Percent complete: 86.7%; Average loss: 2.7749\n",
      "Iteration: 3467; Percent complete: 86.7%; Average loss: 2.8157\n",
      "Iteration: 3468; Percent complete: 86.7%; Average loss: 2.8983\n",
      "Iteration: 3469; Percent complete: 86.7%; Average loss: 2.4657\n",
      "Iteration: 3470; Percent complete: 86.8%; Average loss: 2.5929\n",
      "Iteration: 3471; Percent complete: 86.8%; Average loss: 2.6978\n",
      "Iteration: 3472; Percent complete: 86.8%; Average loss: 2.7655\n",
      "Iteration: 3473; Percent complete: 86.8%; Average loss: 2.7834\n",
      "Iteration: 3474; Percent complete: 86.9%; Average loss: 2.6205\n",
      "Iteration: 3475; Percent complete: 86.9%; Average loss: 3.1130\n",
      "Iteration: 3476; Percent complete: 86.9%; Average loss: 2.8963\n",
      "Iteration: 3477; Percent complete: 86.9%; Average loss: 2.6728\n",
      "Iteration: 3478; Percent complete: 87.0%; Average loss: 2.6170\n",
      "Iteration: 3479; Percent complete: 87.0%; Average loss: 2.5341\n",
      "Iteration: 3480; Percent complete: 87.0%; Average loss: 2.7674\n",
      "Iteration: 3481; Percent complete: 87.0%; Average loss: 2.7377\n",
      "Iteration: 3482; Percent complete: 87.1%; Average loss: 2.7382\n",
      "Iteration: 3483; Percent complete: 87.1%; Average loss: 2.8096\n",
      "Iteration: 3484; Percent complete: 87.1%; Average loss: 2.7135\n",
      "Iteration: 3485; Percent complete: 87.1%; Average loss: 2.4331\n",
      "Iteration: 3486; Percent complete: 87.2%; Average loss: 2.7108\n",
      "Iteration: 3487; Percent complete: 87.2%; Average loss: 2.9737\n",
      "Iteration: 3488; Percent complete: 87.2%; Average loss: 2.7464\n",
      "Iteration: 3489; Percent complete: 87.2%; Average loss: 2.6465\n",
      "Iteration: 3490; Percent complete: 87.2%; Average loss: 2.6942\n",
      "Iteration: 3491; Percent complete: 87.3%; Average loss: 2.7851\n",
      "Iteration: 3492; Percent complete: 87.3%; Average loss: 2.8096\n",
      "Iteration: 3493; Percent complete: 87.3%; Average loss: 2.3613\n",
      "Iteration: 3494; Percent complete: 87.4%; Average loss: 2.7378\n",
      "Iteration: 3495; Percent complete: 87.4%; Average loss: 2.5861\n",
      "Iteration: 3496; Percent complete: 87.4%; Average loss: 2.6652\n",
      "Iteration: 3497; Percent complete: 87.4%; Average loss: 2.7339\n",
      "Iteration: 3498; Percent complete: 87.5%; Average loss: 2.6791\n",
      "Iteration: 3499; Percent complete: 87.5%; Average loss: 2.5777\n",
      "Iteration: 3500; Percent complete: 87.5%; Average loss: 2.7396\n",
      "Iteration: 3501; Percent complete: 87.5%; Average loss: 2.5328\n",
      "Iteration: 3502; Percent complete: 87.5%; Average loss: 2.8306\n",
      "Iteration: 3503; Percent complete: 87.6%; Average loss: 2.7087\n",
      "Iteration: 3504; Percent complete: 87.6%; Average loss: 2.5692\n",
      "Iteration: 3505; Percent complete: 87.6%; Average loss: 2.7528\n",
      "Iteration: 3506; Percent complete: 87.6%; Average loss: 2.9412\n",
      "Iteration: 3507; Percent complete: 87.7%; Average loss: 2.7885\n",
      "Iteration: 3508; Percent complete: 87.7%; Average loss: 2.8945\n",
      "Iteration: 3509; Percent complete: 87.7%; Average loss: 2.6746\n",
      "Iteration: 3510; Percent complete: 87.8%; Average loss: 3.0065\n",
      "Iteration: 3511; Percent complete: 87.8%; Average loss: 2.7728\n",
      "Iteration: 3512; Percent complete: 87.8%; Average loss: 2.7883\n",
      "Iteration: 3513; Percent complete: 87.8%; Average loss: 2.6240\n",
      "Iteration: 3514; Percent complete: 87.8%; Average loss: 2.5748\n",
      "Iteration: 3515; Percent complete: 87.9%; Average loss: 2.8797\n",
      "Iteration: 3516; Percent complete: 87.9%; Average loss: 2.8208\n",
      "Iteration: 3517; Percent complete: 87.9%; Average loss: 2.8599\n",
      "Iteration: 3518; Percent complete: 87.9%; Average loss: 2.8481\n",
      "Iteration: 3519; Percent complete: 88.0%; Average loss: 3.0338\n",
      "Iteration: 3520; Percent complete: 88.0%; Average loss: 2.6188\n",
      "Iteration: 3521; Percent complete: 88.0%; Average loss: 2.6465\n",
      "Iteration: 3522; Percent complete: 88.0%; Average loss: 2.6534\n",
      "Iteration: 3523; Percent complete: 88.1%; Average loss: 2.6857\n",
      "Iteration: 3524; Percent complete: 88.1%; Average loss: 2.6625\n",
      "Iteration: 3525; Percent complete: 88.1%; Average loss: 2.8716\n",
      "Iteration: 3526; Percent complete: 88.1%; Average loss: 2.7261\n",
      "Iteration: 3527; Percent complete: 88.2%; Average loss: 2.6160\n",
      "Iteration: 3528; Percent complete: 88.2%; Average loss: 2.7524\n",
      "Iteration: 3529; Percent complete: 88.2%; Average loss: 2.6200\n",
      "Iteration: 3530; Percent complete: 88.2%; Average loss: 2.6615\n",
      "Iteration: 3531; Percent complete: 88.3%; Average loss: 2.8005\n",
      "Iteration: 3532; Percent complete: 88.3%; Average loss: 2.8288\n",
      "Iteration: 3533; Percent complete: 88.3%; Average loss: 2.8611\n",
      "Iteration: 3534; Percent complete: 88.3%; Average loss: 2.8983\n",
      "Iteration: 3535; Percent complete: 88.4%; Average loss: 2.7615\n",
      "Iteration: 3536; Percent complete: 88.4%; Average loss: 2.8268\n",
      "Iteration: 3537; Percent complete: 88.4%; Average loss: 2.9086\n",
      "Iteration: 3538; Percent complete: 88.4%; Average loss: 2.6783\n",
      "Iteration: 3539; Percent complete: 88.5%; Average loss: 2.7841\n",
      "Iteration: 3540; Percent complete: 88.5%; Average loss: 2.7108\n",
      "Iteration: 3541; Percent complete: 88.5%; Average loss: 2.8136\n",
      "Iteration: 3542; Percent complete: 88.5%; Average loss: 2.6104\n",
      "Iteration: 3543; Percent complete: 88.6%; Average loss: 2.8951\n",
      "Iteration: 3544; Percent complete: 88.6%; Average loss: 2.4101\n",
      "Iteration: 3545; Percent complete: 88.6%; Average loss: 2.6199\n",
      "Iteration: 3546; Percent complete: 88.6%; Average loss: 2.6309\n",
      "Iteration: 3547; Percent complete: 88.7%; Average loss: 2.8600\n",
      "Iteration: 3548; Percent complete: 88.7%; Average loss: 2.8216\n",
      "Iteration: 3549; Percent complete: 88.7%; Average loss: 2.9490\n",
      "Iteration: 3550; Percent complete: 88.8%; Average loss: 2.7212\n",
      "Iteration: 3551; Percent complete: 88.8%; Average loss: 2.7770\n",
      "Iteration: 3552; Percent complete: 88.8%; Average loss: 2.8160\n",
      "Iteration: 3553; Percent complete: 88.8%; Average loss: 2.6862\n",
      "Iteration: 3554; Percent complete: 88.8%; Average loss: 2.7213\n",
      "Iteration: 3555; Percent complete: 88.9%; Average loss: 2.8432\n",
      "Iteration: 3556; Percent complete: 88.9%; Average loss: 2.6793\n",
      "Iteration: 3557; Percent complete: 88.9%; Average loss: 2.5183\n",
      "Iteration: 3558; Percent complete: 88.9%; Average loss: 2.6707\n",
      "Iteration: 3559; Percent complete: 89.0%; Average loss: 2.6565\n",
      "Iteration: 3560; Percent complete: 89.0%; Average loss: 2.6446\n",
      "Iteration: 3561; Percent complete: 89.0%; Average loss: 2.6336\n",
      "Iteration: 3562; Percent complete: 89.0%; Average loss: 2.5474\n",
      "Iteration: 3563; Percent complete: 89.1%; Average loss: 2.6794\n",
      "Iteration: 3564; Percent complete: 89.1%; Average loss: 2.8952\n",
      "Iteration: 3565; Percent complete: 89.1%; Average loss: 2.7600\n",
      "Iteration: 3566; Percent complete: 89.1%; Average loss: 3.0793\n",
      "Iteration: 3567; Percent complete: 89.2%; Average loss: 3.0230\n",
      "Iteration: 3568; Percent complete: 89.2%; Average loss: 2.9124\n",
      "Iteration: 3569; Percent complete: 89.2%; Average loss: 2.6877\n",
      "Iteration: 3570; Percent complete: 89.2%; Average loss: 2.7475\n",
      "Iteration: 3571; Percent complete: 89.3%; Average loss: 2.7526\n",
      "Iteration: 3572; Percent complete: 89.3%; Average loss: 2.5224\n",
      "Iteration: 3573; Percent complete: 89.3%; Average loss: 2.6916\n",
      "Iteration: 3574; Percent complete: 89.3%; Average loss: 2.8112\n",
      "Iteration: 3575; Percent complete: 89.4%; Average loss: 2.6253\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 3576; Percent complete: 89.4%; Average loss: 2.9248\n",
      "Iteration: 3577; Percent complete: 89.4%; Average loss: 2.5267\n",
      "Iteration: 3578; Percent complete: 89.5%; Average loss: 2.9129\n",
      "Iteration: 3579; Percent complete: 89.5%; Average loss: 2.7838\n",
      "Iteration: 3580; Percent complete: 89.5%; Average loss: 2.8030\n",
      "Iteration: 3581; Percent complete: 89.5%; Average loss: 2.7126\n",
      "Iteration: 3582; Percent complete: 89.5%; Average loss: 2.7154\n",
      "Iteration: 3583; Percent complete: 89.6%; Average loss: 2.7281\n",
      "Iteration: 3584; Percent complete: 89.6%; Average loss: 2.6861\n",
      "Iteration: 3585; Percent complete: 89.6%; Average loss: 2.7585\n",
      "Iteration: 3586; Percent complete: 89.6%; Average loss: 2.6664\n",
      "Iteration: 3587; Percent complete: 89.7%; Average loss: 2.8414\n",
      "Iteration: 3588; Percent complete: 89.7%; Average loss: 2.4561\n",
      "Iteration: 3589; Percent complete: 89.7%; Average loss: 2.6674\n",
      "Iteration: 3590; Percent complete: 89.8%; Average loss: 2.6141\n",
      "Iteration: 3591; Percent complete: 89.8%; Average loss: 2.9511\n",
      "Iteration: 3592; Percent complete: 89.8%; Average loss: 2.7662\n",
      "Iteration: 3593; Percent complete: 89.8%; Average loss: 2.8567\n",
      "Iteration: 3594; Percent complete: 89.8%; Average loss: 2.5873\n",
      "Iteration: 3595; Percent complete: 89.9%; Average loss: 2.7416\n",
      "Iteration: 3596; Percent complete: 89.9%; Average loss: 2.8619\n",
      "Iteration: 3597; Percent complete: 89.9%; Average loss: 2.9335\n",
      "Iteration: 3598; Percent complete: 90.0%; Average loss: 2.5650\n",
      "Iteration: 3599; Percent complete: 90.0%; Average loss: 2.5187\n",
      "Iteration: 3600; Percent complete: 90.0%; Average loss: 2.6109\n",
      "Iteration: 3601; Percent complete: 90.0%; Average loss: 2.7101\n",
      "Iteration: 3602; Percent complete: 90.0%; Average loss: 2.7266\n",
      "Iteration: 3603; Percent complete: 90.1%; Average loss: 2.8216\n",
      "Iteration: 3604; Percent complete: 90.1%; Average loss: 2.6939\n",
      "Iteration: 3605; Percent complete: 90.1%; Average loss: 2.6997\n",
      "Iteration: 3606; Percent complete: 90.1%; Average loss: 2.8914\n",
      "Iteration: 3607; Percent complete: 90.2%; Average loss: 2.5719\n",
      "Iteration: 3608; Percent complete: 90.2%; Average loss: 2.7485\n",
      "Iteration: 3609; Percent complete: 90.2%; Average loss: 2.8296\n",
      "Iteration: 3610; Percent complete: 90.2%; Average loss: 2.5532\n",
      "Iteration: 3611; Percent complete: 90.3%; Average loss: 2.7475\n",
      "Iteration: 3612; Percent complete: 90.3%; Average loss: 2.5617\n",
      "Iteration: 3613; Percent complete: 90.3%; Average loss: 2.7383\n",
      "Iteration: 3614; Percent complete: 90.3%; Average loss: 2.5896\n",
      "Iteration: 3615; Percent complete: 90.4%; Average loss: 2.6618\n",
      "Iteration: 3616; Percent complete: 90.4%; Average loss: 2.7743\n",
      "Iteration: 3617; Percent complete: 90.4%; Average loss: 2.7557\n",
      "Iteration: 3618; Percent complete: 90.5%; Average loss: 2.6723\n",
      "Iteration: 3619; Percent complete: 90.5%; Average loss: 2.7891\n",
      "Iteration: 3620; Percent complete: 90.5%; Average loss: 2.7879\n",
      "Iteration: 3621; Percent complete: 90.5%; Average loss: 2.7601\n",
      "Iteration: 3622; Percent complete: 90.5%; Average loss: 2.7972\n",
      "Iteration: 3623; Percent complete: 90.6%; Average loss: 2.8524\n",
      "Iteration: 3624; Percent complete: 90.6%; Average loss: 2.7623\n",
      "Iteration: 3625; Percent complete: 90.6%; Average loss: 2.7213\n",
      "Iteration: 3626; Percent complete: 90.6%; Average loss: 2.6552\n",
      "Iteration: 3627; Percent complete: 90.7%; Average loss: 2.9141\n",
      "Iteration: 3628; Percent complete: 90.7%; Average loss: 2.6721\n",
      "Iteration: 3629; Percent complete: 90.7%; Average loss: 2.5925\n",
      "Iteration: 3630; Percent complete: 90.8%; Average loss: 2.6528\n",
      "Iteration: 3631; Percent complete: 90.8%; Average loss: 2.7107\n",
      "Iteration: 3632; Percent complete: 90.8%; Average loss: 2.7699\n",
      "Iteration: 3633; Percent complete: 90.8%; Average loss: 2.6101\n",
      "Iteration: 3634; Percent complete: 90.8%; Average loss: 2.6814\n",
      "Iteration: 3635; Percent complete: 90.9%; Average loss: 2.7569\n",
      "Iteration: 3636; Percent complete: 90.9%; Average loss: 2.6381\n",
      "Iteration: 3637; Percent complete: 90.9%; Average loss: 2.5971\n",
      "Iteration: 3638; Percent complete: 91.0%; Average loss: 2.8414\n",
      "Iteration: 3639; Percent complete: 91.0%; Average loss: 2.5013\n",
      "Iteration: 3640; Percent complete: 91.0%; Average loss: 2.5737\n",
      "Iteration: 3641; Percent complete: 91.0%; Average loss: 2.8700\n",
      "Iteration: 3642; Percent complete: 91.0%; Average loss: 3.0073\n",
      "Iteration: 3643; Percent complete: 91.1%; Average loss: 2.7416\n",
      "Iteration: 3644; Percent complete: 91.1%; Average loss: 2.9465\n",
      "Iteration: 3645; Percent complete: 91.1%; Average loss: 2.3905\n",
      "Iteration: 3646; Percent complete: 91.1%; Average loss: 2.5014\n",
      "Iteration: 3647; Percent complete: 91.2%; Average loss: 2.5769\n",
      "Iteration: 3648; Percent complete: 91.2%; Average loss: 2.7215\n",
      "Iteration: 3649; Percent complete: 91.2%; Average loss: 2.5977\n",
      "Iteration: 3650; Percent complete: 91.2%; Average loss: 2.8418\n",
      "Iteration: 3651; Percent complete: 91.3%; Average loss: 2.5989\n",
      "Iteration: 3652; Percent complete: 91.3%; Average loss: 2.7444\n",
      "Iteration: 3653; Percent complete: 91.3%; Average loss: 2.6966\n",
      "Iteration: 3654; Percent complete: 91.3%; Average loss: 2.6341\n",
      "Iteration: 3655; Percent complete: 91.4%; Average loss: 2.8735\n",
      "Iteration: 3656; Percent complete: 91.4%; Average loss: 2.5850\n",
      "Iteration: 3657; Percent complete: 91.4%; Average loss: 2.6253\n",
      "Iteration: 3658; Percent complete: 91.5%; Average loss: 2.4948\n",
      "Iteration: 3659; Percent complete: 91.5%; Average loss: 2.6895\n",
      "Iteration: 3660; Percent complete: 91.5%; Average loss: 2.7559\n",
      "Iteration: 3661; Percent complete: 91.5%; Average loss: 2.6887\n",
      "Iteration: 3662; Percent complete: 91.5%; Average loss: 2.3718\n",
      "Iteration: 3663; Percent complete: 91.6%; Average loss: 2.6588\n",
      "Iteration: 3664; Percent complete: 91.6%; Average loss: 2.7767\n",
      "Iteration: 3665; Percent complete: 91.6%; Average loss: 2.6482\n",
      "Iteration: 3666; Percent complete: 91.6%; Average loss: 2.6184\n",
      "Iteration: 3667; Percent complete: 91.7%; Average loss: 2.4938\n",
      "Iteration: 3668; Percent complete: 91.7%; Average loss: 2.5552\n",
      "Iteration: 3669; Percent complete: 91.7%; Average loss: 2.6599\n",
      "Iteration: 3670; Percent complete: 91.8%; Average loss: 2.8279\n",
      "Iteration: 3671; Percent complete: 91.8%; Average loss: 2.7633\n",
      "Iteration: 3672; Percent complete: 91.8%; Average loss: 2.8893\n",
      "Iteration: 3673; Percent complete: 91.8%; Average loss: 2.6357\n",
      "Iteration: 3674; Percent complete: 91.8%; Average loss: 2.8606\n",
      "Iteration: 3675; Percent complete: 91.9%; Average loss: 2.6596\n",
      "Iteration: 3676; Percent complete: 91.9%; Average loss: 2.7527\n",
      "Iteration: 3677; Percent complete: 91.9%; Average loss: 2.6398\n",
      "Iteration: 3678; Percent complete: 92.0%; Average loss: 2.7891\n",
      "Iteration: 3679; Percent complete: 92.0%; Average loss: 2.8214\n",
      "Iteration: 3680; Percent complete: 92.0%; Average loss: 2.8782\n",
      "Iteration: 3681; Percent complete: 92.0%; Average loss: 2.6989\n",
      "Iteration: 3682; Percent complete: 92.0%; Average loss: 2.5859\n",
      "Iteration: 3683; Percent complete: 92.1%; Average loss: 2.6857\n",
      "Iteration: 3684; Percent complete: 92.1%; Average loss: 2.8402\n",
      "Iteration: 3685; Percent complete: 92.1%; Average loss: 2.7888\n",
      "Iteration: 3686; Percent complete: 92.2%; Average loss: 2.4878\n",
      "Iteration: 3687; Percent complete: 92.2%; Average loss: 2.6479\n",
      "Iteration: 3688; Percent complete: 92.2%; Average loss: 2.6702\n",
      "Iteration: 3689; Percent complete: 92.2%; Average loss: 2.8420\n",
      "Iteration: 3690; Percent complete: 92.2%; Average loss: 2.9170\n",
      "Iteration: 3691; Percent complete: 92.3%; Average loss: 2.6839\n",
      "Iteration: 3692; Percent complete: 92.3%; Average loss: 2.6138\n",
      "Iteration: 3693; Percent complete: 92.3%; Average loss: 2.8182\n",
      "Iteration: 3694; Percent complete: 92.3%; Average loss: 2.6555\n",
      "Iteration: 3695; Percent complete: 92.4%; Average loss: 2.5642\n",
      "Iteration: 3696; Percent complete: 92.4%; Average loss: 2.6237\n",
      "Iteration: 3697; Percent complete: 92.4%; Average loss: 2.6902\n",
      "Iteration: 3698; Percent complete: 92.5%; Average loss: 2.6514\n",
      "Iteration: 3699; Percent complete: 92.5%; Average loss: 2.5507\n",
      "Iteration: 3700; Percent complete: 92.5%; Average loss: 2.6523\n",
      "Iteration: 3701; Percent complete: 92.5%; Average loss: 2.7187\n",
      "Iteration: 3702; Percent complete: 92.5%; Average loss: 2.6298\n",
      "Iteration: 3703; Percent complete: 92.6%; Average loss: 2.3786\n",
      "Iteration: 3704; Percent complete: 92.6%; Average loss: 2.6087\n",
      "Iteration: 3705; Percent complete: 92.6%; Average loss: 2.6909\n",
      "Iteration: 3706; Percent complete: 92.7%; Average loss: 2.7668\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 3707; Percent complete: 92.7%; Average loss: 2.7055\n",
      "Iteration: 3708; Percent complete: 92.7%; Average loss: 2.4144\n",
      "Iteration: 3709; Percent complete: 92.7%; Average loss: 2.7195\n",
      "Iteration: 3710; Percent complete: 92.8%; Average loss: 2.7861\n",
      "Iteration: 3711; Percent complete: 92.8%; Average loss: 3.0476\n",
      "Iteration: 3712; Percent complete: 92.8%; Average loss: 2.8307\n",
      "Iteration: 3713; Percent complete: 92.8%; Average loss: 2.6465\n",
      "Iteration: 3714; Percent complete: 92.8%; Average loss: 2.6351\n",
      "Iteration: 3715; Percent complete: 92.9%; Average loss: 2.7614\n",
      "Iteration: 3716; Percent complete: 92.9%; Average loss: 2.5100\n",
      "Iteration: 3717; Percent complete: 92.9%; Average loss: 2.5466\n",
      "Iteration: 3718; Percent complete: 93.0%; Average loss: 2.7574\n",
      "Iteration: 3719; Percent complete: 93.0%; Average loss: 2.7296\n",
      "Iteration: 3720; Percent complete: 93.0%; Average loss: 2.4860\n",
      "Iteration: 3721; Percent complete: 93.0%; Average loss: 2.7815\n",
      "Iteration: 3722; Percent complete: 93.0%; Average loss: 2.8177\n",
      "Iteration: 3723; Percent complete: 93.1%; Average loss: 2.8164\n",
      "Iteration: 3724; Percent complete: 93.1%; Average loss: 2.6353\n",
      "Iteration: 3725; Percent complete: 93.1%; Average loss: 2.7289\n",
      "Iteration: 3726; Percent complete: 93.2%; Average loss: 2.7367\n",
      "Iteration: 3727; Percent complete: 93.2%; Average loss: 2.6626\n",
      "Iteration: 3728; Percent complete: 93.2%; Average loss: 2.6214\n",
      "Iteration: 3729; Percent complete: 93.2%; Average loss: 2.9727\n",
      "Iteration: 3730; Percent complete: 93.2%; Average loss: 2.9181\n",
      "Iteration: 3731; Percent complete: 93.3%; Average loss: 2.7596\n",
      "Iteration: 3732; Percent complete: 93.3%; Average loss: 2.5631\n",
      "Iteration: 3733; Percent complete: 93.3%; Average loss: 2.6426\n",
      "Iteration: 3734; Percent complete: 93.3%; Average loss: 2.6476\n",
      "Iteration: 3735; Percent complete: 93.4%; Average loss: 2.8204\n",
      "Iteration: 3736; Percent complete: 93.4%; Average loss: 2.6168\n",
      "Iteration: 3737; Percent complete: 93.4%; Average loss: 2.6924\n",
      "Iteration: 3738; Percent complete: 93.5%; Average loss: 2.5175\n",
      "Iteration: 3739; Percent complete: 93.5%; Average loss: 2.5364\n",
      "Iteration: 3740; Percent complete: 93.5%; Average loss: 2.7655\n",
      "Iteration: 3741; Percent complete: 93.5%; Average loss: 2.7984\n",
      "Iteration: 3742; Percent complete: 93.5%; Average loss: 2.8330\n",
      "Iteration: 3743; Percent complete: 93.6%; Average loss: 2.9450\n",
      "Iteration: 3744; Percent complete: 93.6%; Average loss: 2.6987\n",
      "Iteration: 3745; Percent complete: 93.6%; Average loss: 2.2557\n",
      "Iteration: 3746; Percent complete: 93.7%; Average loss: 2.5544\n",
      "Iteration: 3747; Percent complete: 93.7%; Average loss: 2.5991\n",
      "Iteration: 3748; Percent complete: 93.7%; Average loss: 2.5877\n",
      "Iteration: 3749; Percent complete: 93.7%; Average loss: 2.9496\n",
      "Iteration: 3750; Percent complete: 93.8%; Average loss: 2.6299\n",
      "Iteration: 3751; Percent complete: 93.8%; Average loss: 2.6606\n",
      "Iteration: 3752; Percent complete: 93.8%; Average loss: 2.7309\n",
      "Iteration: 3753; Percent complete: 93.8%; Average loss: 2.7777\n",
      "Iteration: 3754; Percent complete: 93.8%; Average loss: 2.7347\n",
      "Iteration: 3755; Percent complete: 93.9%; Average loss: 2.7123\n",
      "Iteration: 3756; Percent complete: 93.9%; Average loss: 2.7026\n",
      "Iteration: 3757; Percent complete: 93.9%; Average loss: 2.6615\n",
      "Iteration: 3758; Percent complete: 94.0%; Average loss: 2.7454\n",
      "Iteration: 3759; Percent complete: 94.0%; Average loss: 2.5401\n",
      "Iteration: 3760; Percent complete: 94.0%; Average loss: 2.7286\n",
      "Iteration: 3761; Percent complete: 94.0%; Average loss: 2.9179\n",
      "Iteration: 3762; Percent complete: 94.0%; Average loss: 2.7264\n",
      "Iteration: 3763; Percent complete: 94.1%; Average loss: 2.8474\n",
      "Iteration: 3764; Percent complete: 94.1%; Average loss: 2.5607\n",
      "Iteration: 3765; Percent complete: 94.1%; Average loss: 2.8712\n",
      "Iteration: 3766; Percent complete: 94.2%; Average loss: 2.5776\n",
      "Iteration: 3767; Percent complete: 94.2%; Average loss: 2.6970\n",
      "Iteration: 3768; Percent complete: 94.2%; Average loss: 2.6589\n",
      "Iteration: 3769; Percent complete: 94.2%; Average loss: 2.6044\n",
      "Iteration: 3770; Percent complete: 94.2%; Average loss: 2.6539\n",
      "Iteration: 3771; Percent complete: 94.3%; Average loss: 2.7591\n",
      "Iteration: 3772; Percent complete: 94.3%; Average loss: 2.7658\n",
      "Iteration: 3773; Percent complete: 94.3%; Average loss: 2.4350\n",
      "Iteration: 3774; Percent complete: 94.3%; Average loss: 2.6099\n",
      "Iteration: 3775; Percent complete: 94.4%; Average loss: 2.5480\n",
      "Iteration: 3776; Percent complete: 94.4%; Average loss: 2.6720\n",
      "Iteration: 3777; Percent complete: 94.4%; Average loss: 2.5581\n",
      "Iteration: 3778; Percent complete: 94.5%; Average loss: 2.5962\n",
      "Iteration: 3779; Percent complete: 94.5%; Average loss: 2.5886\n",
      "Iteration: 3780; Percent complete: 94.5%; Average loss: 2.8732\n",
      "Iteration: 3781; Percent complete: 94.5%; Average loss: 2.7200\n",
      "Iteration: 3782; Percent complete: 94.5%; Average loss: 2.6651\n",
      "Iteration: 3783; Percent complete: 94.6%; Average loss: 2.5995\n",
      "Iteration: 3784; Percent complete: 94.6%; Average loss: 2.5264\n",
      "Iteration: 3785; Percent complete: 94.6%; Average loss: 2.5688\n",
      "Iteration: 3786; Percent complete: 94.7%; Average loss: 2.5474\n",
      "Iteration: 3787; Percent complete: 94.7%; Average loss: 2.6430\n",
      "Iteration: 3788; Percent complete: 94.7%; Average loss: 2.7447\n",
      "Iteration: 3789; Percent complete: 94.7%; Average loss: 2.6492\n",
      "Iteration: 3790; Percent complete: 94.8%; Average loss: 2.6412\n",
      "Iteration: 3791; Percent complete: 94.8%; Average loss: 2.6991\n",
      "Iteration: 3792; Percent complete: 94.8%; Average loss: 2.8032\n",
      "Iteration: 3793; Percent complete: 94.8%; Average loss: 2.6902\n",
      "Iteration: 3794; Percent complete: 94.8%; Average loss: 2.6427\n",
      "Iteration: 3795; Percent complete: 94.9%; Average loss: 2.7185\n",
      "Iteration: 3796; Percent complete: 94.9%; Average loss: 2.7377\n",
      "Iteration: 3797; Percent complete: 94.9%; Average loss: 2.7356\n",
      "Iteration: 3798; Percent complete: 95.0%; Average loss: 2.6011\n",
      "Iteration: 3799; Percent complete: 95.0%; Average loss: 2.7883\n",
      "Iteration: 3800; Percent complete: 95.0%; Average loss: 2.5561\n",
      "Iteration: 3801; Percent complete: 95.0%; Average loss: 2.7435\n",
      "Iteration: 3802; Percent complete: 95.0%; Average loss: 2.5737\n",
      "Iteration: 3803; Percent complete: 95.1%; Average loss: 2.7628\n",
      "Iteration: 3804; Percent complete: 95.1%; Average loss: 2.6784\n",
      "Iteration: 3805; Percent complete: 95.1%; Average loss: 2.5678\n",
      "Iteration: 3806; Percent complete: 95.2%; Average loss: 2.5356\n",
      "Iteration: 3807; Percent complete: 95.2%; Average loss: 2.7532\n",
      "Iteration: 3808; Percent complete: 95.2%; Average loss: 2.7997\n",
      "Iteration: 3809; Percent complete: 95.2%; Average loss: 2.5890\n",
      "Iteration: 3810; Percent complete: 95.2%; Average loss: 2.6125\n",
      "Iteration: 3811; Percent complete: 95.3%; Average loss: 2.6325\n",
      "Iteration: 3812; Percent complete: 95.3%; Average loss: 2.8306\n",
      "Iteration: 3813; Percent complete: 95.3%; Average loss: 2.5420\n",
      "Iteration: 3814; Percent complete: 95.3%; Average loss: 2.7690\n",
      "Iteration: 3815; Percent complete: 95.4%; Average loss: 2.4526\n",
      "Iteration: 3816; Percent complete: 95.4%; Average loss: 2.9320\n",
      "Iteration: 3817; Percent complete: 95.4%; Average loss: 2.4462\n",
      "Iteration: 3818; Percent complete: 95.5%; Average loss: 2.6262\n",
      "Iteration: 3819; Percent complete: 95.5%; Average loss: 2.6223\n",
      "Iteration: 3820; Percent complete: 95.5%; Average loss: 2.5598\n",
      "Iteration: 3821; Percent complete: 95.5%; Average loss: 2.7554\n",
      "Iteration: 3822; Percent complete: 95.5%; Average loss: 2.7194\n",
      "Iteration: 3823; Percent complete: 95.6%; Average loss: 2.6248\n",
      "Iteration: 3824; Percent complete: 95.6%; Average loss: 2.7369\n",
      "Iteration: 3825; Percent complete: 95.6%; Average loss: 2.7530\n",
      "Iteration: 3826; Percent complete: 95.7%; Average loss: 2.5979\n",
      "Iteration: 3827; Percent complete: 95.7%; Average loss: 2.5973\n",
      "Iteration: 3828; Percent complete: 95.7%; Average loss: 2.3900\n",
      "Iteration: 3829; Percent complete: 95.7%; Average loss: 2.6032\n",
      "Iteration: 3830; Percent complete: 95.8%; Average loss: 2.6199\n",
      "Iteration: 3831; Percent complete: 95.8%; Average loss: 2.3446\n",
      "Iteration: 3832; Percent complete: 95.8%; Average loss: 2.7255\n",
      "Iteration: 3833; Percent complete: 95.8%; Average loss: 2.5747\n",
      "Iteration: 3834; Percent complete: 95.9%; Average loss: 2.6415\n",
      "Iteration: 3835; Percent complete: 95.9%; Average loss: 2.6005\n",
      "Iteration: 3836; Percent complete: 95.9%; Average loss: 2.6089\n",
      "Iteration: 3837; Percent complete: 95.9%; Average loss: 2.7866\n",
      "Iteration: 3838; Percent complete: 96.0%; Average loss: 2.3840\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 3839; Percent complete: 96.0%; Average loss: 2.6191\n",
      "Iteration: 3840; Percent complete: 96.0%; Average loss: 2.6127\n",
      "Iteration: 3841; Percent complete: 96.0%; Average loss: 2.4573\n",
      "Iteration: 3842; Percent complete: 96.0%; Average loss: 2.8176\n",
      "Iteration: 3843; Percent complete: 96.1%; Average loss: 2.7865\n",
      "Iteration: 3844; Percent complete: 96.1%; Average loss: 2.5060\n",
      "Iteration: 3845; Percent complete: 96.1%; Average loss: 2.5852\n",
      "Iteration: 3846; Percent complete: 96.2%; Average loss: 2.9436\n",
      "Iteration: 3847; Percent complete: 96.2%; Average loss: 2.6242\n",
      "Iteration: 3848; Percent complete: 96.2%; Average loss: 2.5748\n",
      "Iteration: 3849; Percent complete: 96.2%; Average loss: 2.6562\n",
      "Iteration: 3850; Percent complete: 96.2%; Average loss: 2.9179\n",
      "Iteration: 3851; Percent complete: 96.3%; Average loss: 2.6268\n",
      "Iteration: 3852; Percent complete: 96.3%; Average loss: 2.8573\n",
      "Iteration: 3853; Percent complete: 96.3%; Average loss: 2.8675\n",
      "Iteration: 3854; Percent complete: 96.4%; Average loss: 2.5374\n",
      "Iteration: 3855; Percent complete: 96.4%; Average loss: 2.7249\n",
      "Iteration: 3856; Percent complete: 96.4%; Average loss: 2.4563\n",
      "Iteration: 3857; Percent complete: 96.4%; Average loss: 2.6011\n",
      "Iteration: 3858; Percent complete: 96.5%; Average loss: 2.6787\n",
      "Iteration: 3859; Percent complete: 96.5%; Average loss: 2.4460\n",
      "Iteration: 3860; Percent complete: 96.5%; Average loss: 2.5215\n",
      "Iteration: 3861; Percent complete: 96.5%; Average loss: 2.8377\n",
      "Iteration: 3862; Percent complete: 96.5%; Average loss: 2.7761\n",
      "Iteration: 3863; Percent complete: 96.6%; Average loss: 2.6543\n",
      "Iteration: 3864; Percent complete: 96.6%; Average loss: 2.7475\n",
      "Iteration: 3865; Percent complete: 96.6%; Average loss: 2.6102\n",
      "Iteration: 3866; Percent complete: 96.7%; Average loss: 2.6556\n",
      "Iteration: 3867; Percent complete: 96.7%; Average loss: 2.9637\n",
      "Iteration: 3868; Percent complete: 96.7%; Average loss: 2.6228\n",
      "Iteration: 3869; Percent complete: 96.7%; Average loss: 2.4269\n",
      "Iteration: 3870; Percent complete: 96.8%; Average loss: 2.6760\n",
      "Iteration: 3871; Percent complete: 96.8%; Average loss: 2.6656\n",
      "Iteration: 3872; Percent complete: 96.8%; Average loss: 2.6858\n",
      "Iteration: 3873; Percent complete: 96.8%; Average loss: 2.7133\n",
      "Iteration: 3874; Percent complete: 96.9%; Average loss: 2.5695\n",
      "Iteration: 3875; Percent complete: 96.9%; Average loss: 2.6635\n",
      "Iteration: 3876; Percent complete: 96.9%; Average loss: 2.6005\n",
      "Iteration: 3877; Percent complete: 96.9%; Average loss: 2.5424\n",
      "Iteration: 3878; Percent complete: 97.0%; Average loss: 2.8022\n",
      "Iteration: 3879; Percent complete: 97.0%; Average loss: 2.6445\n",
      "Iteration: 3880; Percent complete: 97.0%; Average loss: 2.4972\n",
      "Iteration: 3881; Percent complete: 97.0%; Average loss: 2.6585\n",
      "Iteration: 3882; Percent complete: 97.0%; Average loss: 2.7181\n",
      "Iteration: 3883; Percent complete: 97.1%; Average loss: 2.5418\n",
      "Iteration: 3884; Percent complete: 97.1%; Average loss: 2.5990\n",
      "Iteration: 3885; Percent complete: 97.1%; Average loss: 2.4467\n",
      "Iteration: 3886; Percent complete: 97.2%; Average loss: 2.3656\n",
      "Iteration: 3887; Percent complete: 97.2%; Average loss: 2.6587\n",
      "Iteration: 3888; Percent complete: 97.2%; Average loss: 2.6803\n",
      "Iteration: 3889; Percent complete: 97.2%; Average loss: 2.5130\n",
      "Iteration: 3890; Percent complete: 97.2%; Average loss: 2.5484\n",
      "Iteration: 3891; Percent complete: 97.3%; Average loss: 2.6199\n",
      "Iteration: 3892; Percent complete: 97.3%; Average loss: 2.5344\n",
      "Iteration: 3893; Percent complete: 97.3%; Average loss: 2.3908\n",
      "Iteration: 3894; Percent complete: 97.4%; Average loss: 2.4508\n",
      "Iteration: 3895; Percent complete: 97.4%; Average loss: 2.6590\n",
      "Iteration: 3896; Percent complete: 97.4%; Average loss: 2.7256\n",
      "Iteration: 3897; Percent complete: 97.4%; Average loss: 2.6178\n",
      "Iteration: 3898; Percent complete: 97.5%; Average loss: 2.9553\n",
      "Iteration: 3899; Percent complete: 97.5%; Average loss: 2.5968\n",
      "Iteration: 3900; Percent complete: 97.5%; Average loss: 2.6224\n",
      "Iteration: 3901; Percent complete: 97.5%; Average loss: 2.5392\n",
      "Iteration: 3902; Percent complete: 97.5%; Average loss: 2.5065\n",
      "Iteration: 3903; Percent complete: 97.6%; Average loss: 2.5972\n",
      "Iteration: 3904; Percent complete: 97.6%; Average loss: 2.8114\n",
      "Iteration: 3905; Percent complete: 97.6%; Average loss: 2.8559\n",
      "Iteration: 3906; Percent complete: 97.7%; Average loss: 2.7682\n",
      "Iteration: 3907; Percent complete: 97.7%; Average loss: 2.7192\n",
      "Iteration: 3908; Percent complete: 97.7%; Average loss: 2.4339\n",
      "Iteration: 3909; Percent complete: 97.7%; Average loss: 2.6729\n",
      "Iteration: 3910; Percent complete: 97.8%; Average loss: 2.6682\n",
      "Iteration: 3911; Percent complete: 97.8%; Average loss: 2.5398\n",
      "Iteration: 3912; Percent complete: 97.8%; Average loss: 2.7899\n",
      "Iteration: 3913; Percent complete: 97.8%; Average loss: 2.6588\n",
      "Iteration: 3914; Percent complete: 97.9%; Average loss: 2.5476\n",
      "Iteration: 3915; Percent complete: 97.9%; Average loss: 2.5859\n",
      "Iteration: 3916; Percent complete: 97.9%; Average loss: 2.6746\n",
      "Iteration: 3917; Percent complete: 97.9%; Average loss: 2.8568\n",
      "Iteration: 3918; Percent complete: 98.0%; Average loss: 2.5171\n",
      "Iteration: 3919; Percent complete: 98.0%; Average loss: 2.6846\n",
      "Iteration: 3920; Percent complete: 98.0%; Average loss: 2.8051\n",
      "Iteration: 3921; Percent complete: 98.0%; Average loss: 2.8052\n",
      "Iteration: 3922; Percent complete: 98.0%; Average loss: 2.5349\n",
      "Iteration: 3923; Percent complete: 98.1%; Average loss: 2.4395\n",
      "Iteration: 3924; Percent complete: 98.1%; Average loss: 2.4496\n",
      "Iteration: 3925; Percent complete: 98.1%; Average loss: 2.7783\n",
      "Iteration: 3926; Percent complete: 98.2%; Average loss: 2.8438\n",
      "Iteration: 3927; Percent complete: 98.2%; Average loss: 2.5768\n",
      "Iteration: 3928; Percent complete: 98.2%; Average loss: 2.4816\n",
      "Iteration: 3929; Percent complete: 98.2%; Average loss: 2.5489\n",
      "Iteration: 3930; Percent complete: 98.2%; Average loss: 2.6193\n",
      "Iteration: 3931; Percent complete: 98.3%; Average loss: 2.5980\n",
      "Iteration: 3932; Percent complete: 98.3%; Average loss: 2.7683\n",
      "Iteration: 3933; Percent complete: 98.3%; Average loss: 2.6802\n",
      "Iteration: 3934; Percent complete: 98.4%; Average loss: 2.4636\n",
      "Iteration: 3935; Percent complete: 98.4%; Average loss: 2.8263\n",
      "Iteration: 3936; Percent complete: 98.4%; Average loss: 2.6897\n",
      "Iteration: 3937; Percent complete: 98.4%; Average loss: 2.4825\n",
      "Iteration: 3938; Percent complete: 98.5%; Average loss: 2.6666\n",
      "Iteration: 3939; Percent complete: 98.5%; Average loss: 2.6894\n",
      "Iteration: 3940; Percent complete: 98.5%; Average loss: 2.6053\n",
      "Iteration: 3941; Percent complete: 98.5%; Average loss: 2.6525\n",
      "Iteration: 3942; Percent complete: 98.6%; Average loss: 2.8806\n",
      "Iteration: 3943; Percent complete: 98.6%; Average loss: 2.6360\n",
      "Iteration: 3944; Percent complete: 98.6%; Average loss: 2.5710\n",
      "Iteration: 3945; Percent complete: 98.6%; Average loss: 2.7098\n",
      "Iteration: 3946; Percent complete: 98.7%; Average loss: 2.4948\n",
      "Iteration: 3947; Percent complete: 98.7%; Average loss: 2.5161\n",
      "Iteration: 3948; Percent complete: 98.7%; Average loss: 2.6985\n",
      "Iteration: 3949; Percent complete: 98.7%; Average loss: 2.5711\n",
      "Iteration: 3950; Percent complete: 98.8%; Average loss: 2.4634\n",
      "Iteration: 3951; Percent complete: 98.8%; Average loss: 2.7164\n",
      "Iteration: 3952; Percent complete: 98.8%; Average loss: 2.5582\n",
      "Iteration: 3953; Percent complete: 98.8%; Average loss: 2.3999\n",
      "Iteration: 3954; Percent complete: 98.9%; Average loss: 2.7081\n",
      "Iteration: 3955; Percent complete: 98.9%; Average loss: 2.6274\n",
      "Iteration: 3956; Percent complete: 98.9%; Average loss: 2.4740\n",
      "Iteration: 3957; Percent complete: 98.9%; Average loss: 2.6079\n",
      "Iteration: 3958; Percent complete: 99.0%; Average loss: 2.7693\n",
      "Iteration: 3959; Percent complete: 99.0%; Average loss: 2.6940\n",
      "Iteration: 3960; Percent complete: 99.0%; Average loss: 2.3449\n",
      "Iteration: 3961; Percent complete: 99.0%; Average loss: 2.4140\n",
      "Iteration: 3962; Percent complete: 99.1%; Average loss: 2.5900\n",
      "Iteration: 3963; Percent complete: 99.1%; Average loss: 2.5705\n",
      "Iteration: 3964; Percent complete: 99.1%; Average loss: 2.3701\n",
      "Iteration: 3965; Percent complete: 99.1%; Average loss: 2.5488\n",
      "Iteration: 3966; Percent complete: 99.2%; Average loss: 2.6352\n",
      "Iteration: 3967; Percent complete: 99.2%; Average loss: 2.5413\n",
      "Iteration: 3968; Percent complete: 99.2%; Average loss: 2.5792\n",
      "Iteration: 3969; Percent complete: 99.2%; Average loss: 2.4696\n",
      "Iteration: 3970; Percent complete: 99.2%; Average loss: 2.5907\n",
      "Iteration: 3971; Percent complete: 99.3%; Average loss: 2.6882\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Iteration: 3972; Percent complete: 99.3%; Average loss: 2.6794\n",
      "Iteration: 3973; Percent complete: 99.3%; Average loss: 2.6937\n",
      "Iteration: 3974; Percent complete: 99.4%; Average loss: 2.6316\n",
      "Iteration: 3975; Percent complete: 99.4%; Average loss: 2.2598\n",
      "Iteration: 3976; Percent complete: 99.4%; Average loss: 2.4558\n",
      "Iteration: 3977; Percent complete: 99.4%; Average loss: 2.8215\n",
      "Iteration: 3978; Percent complete: 99.5%; Average loss: 2.8703\n",
      "Iteration: 3979; Percent complete: 99.5%; Average loss: 2.6670\n",
      "Iteration: 3980; Percent complete: 99.5%; Average loss: 2.4474\n",
      "Iteration: 3981; Percent complete: 99.5%; Average loss: 2.8048\n",
      "Iteration: 3982; Percent complete: 99.6%; Average loss: 2.7439\n",
      "Iteration: 3983; Percent complete: 99.6%; Average loss: 2.5890\n",
      "Iteration: 3984; Percent complete: 99.6%; Average loss: 2.7893\n",
      "Iteration: 3985; Percent complete: 99.6%; Average loss: 2.8107\n",
      "Iteration: 3986; Percent complete: 99.7%; Average loss: 2.6883\n",
      "Iteration: 3987; Percent complete: 99.7%; Average loss: 2.6654\n",
      "Iteration: 3988; Percent complete: 99.7%; Average loss: 2.6437\n",
      "Iteration: 3989; Percent complete: 99.7%; Average loss: 2.6576\n",
      "Iteration: 3990; Percent complete: 99.8%; Average loss: 2.6064\n",
      "Iteration: 3991; Percent complete: 99.8%; Average loss: 2.6044\n",
      "Iteration: 3992; Percent complete: 99.8%; Average loss: 2.5350\n",
      "Iteration: 3993; Percent complete: 99.8%; Average loss: 2.5101\n",
      "Iteration: 3994; Percent complete: 99.9%; Average loss: 2.2420\n",
      "Iteration: 3995; Percent complete: 99.9%; Average loss: 2.5291\n",
      "Iteration: 3996; Percent complete: 99.9%; Average loss: 2.6893\n",
      "Iteration: 3997; Percent complete: 99.9%; Average loss: 2.6797\n",
      "Iteration: 3998; Percent complete: 100.0%; Average loss: 2.4423\n",
      "Iteration: 3999; Percent complete: 100.0%; Average loss: 2.6485\n",
      "Iteration: 4000; Percent complete: 100.0%; Average loss: 2.6193\n"
     ]
    }
   ],
   "source": [
    "# 配置训练的超参数和优化器 \n",
    "clip = 50.0\n",
    "teacher_forcing_ratio = 1.0\n",
    "learning_rate = 0.0001\n",
    "decoder_learning_ratio = 5.0\n",
    "n_iteration = 4000\n",
    "print_every = 1\n",
    "save_every = 500\n",
    "\n",
    "# 设置进入训练模式，从而开启dropout \n",
    "encoder.train()\n",
    "decoder.train()\n",
    "\n",
    "# 初始化优化器 \n",
    "print('Building optimizers ...')\n",
    "encoder_optimizer = optim.Adam(encoder.parameters(), lr=learning_rate)\n",
    "decoder_optimizer = optim.Adam(decoder.parameters(), lr=learning_rate * decoder_learning_ratio)\n",
    "if loadFilename:\n",
    "    encoder_optimizer.load_state_dict(encoder_optimizer_sd)\n",
    "    decoder_optimizer.load_state_dict(decoder_optimizer_sd)\n",
    "\n",
    "# 开始训练\n",
    "print(\"Starting Training!\")\n",
    "trainIters(model_name, voc, pairs, encoder, decoder, encoder_optimizer, decoder_optimizer,\n",
    "           embedding, encoder_n_layers, decoder_n_layers, save_dir, n_iteration, batch_size,\n",
    "           print_every, save_every, clip, corpus_name, loadFilename)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 测试\n",
    "\n",
    "我们使用下面的代码进行测试。\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "> hello\n",
      "Bot: hello .\n",
      "> what's your name?\n",
      "Bot: jacob .\n",
      "> I am sorry.\n",
      "Bot: you re not .\n",
      "> where are you from?\n",
      "Bot: southern .\n",
      "> q\n"
     ]
    }
   ],
   "source": [
    "# 进入eval模式，从而去掉dropout。 \n",
    "encoder.eval()\n",
    "decoder.eval()\n",
    "\n",
    "# 构造searcher对象 \n",
    "searcher = GreedySearchDecoder(encoder, decoder)\n",
    "\n",
    "# 测试\n",
    "evaluateInput(encoder, decoder, searcher, voc)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 结论\n",
    "\n",
    "上面介绍了怎么从零开始训练一个chatbot，读者可以用自己的数据训练一个chatbot试试，看看能不能用来解决一些实际业务问题。\n",
    "\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "py3.6-env",
   "language": "python",
   "name": "py3.6-env"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
